@@ -186,10 +186,17 @@ void Workspaces::initializeWorkspaces() {
186
186
187
187
// get all current workspaces
188
188
auto const workspacesJson = gIPC ->getSocket1JsonReply (" workspaces" );
189
+ auto const workspacerulesJson = gIPC ->getSocket1JsonReply (" workspacerules" );
189
190
auto const clientsJson = gIPC ->getSocket1JsonReply (" clients" );
190
191
191
192
for (Json::Value workspaceJson : workspacesJson) {
192
193
std::string workspaceName = workspaceJson[" name" ].asString ();
194
+ for (Json::Value workspaceRule: workspacerulesJson) {
195
+ if (workspaceJson[" id" ].asString () == workspaceRule[" workspaceString" ].asString () &&
196
+ workspaceRule[" persistent" ] == true ) {
197
+ workspaceJson[" persistent-rule" ] = true ;
198
+ }
199
+ }
193
200
if ((allOutputs () || m_bar.output ->name == workspaceJson[" monitor" ].asString ()) &&
194
201
(!workspaceName.starts_with (" special" ) || showSpecial ()) &&
195
202
!isWorkspaceIgnored (workspaceName)) {
@@ -199,13 +206,11 @@ void Workspaces::initializeWorkspaces() {
199
206
}
200
207
}
201
208
202
- spdlog::debug (" Initializing persistent workspaces" );
209
+ spdlog::debug (" Initializing persistent workspaces from config " );
203
210
if (m_persistentWorkspaceConfig.isObject ()) {
204
211
// a persistent workspace config is defined, so use that instead of workspace rules
205
212
loadPersistentWorkspacesFromConfig (clientsJson);
206
213
}
207
- // load Hyprland's workspace rules
208
- loadPersistentWorkspacesFromWorkspaceRules (clientsJson);
209
214
}
210
215
211
216
bool isDoubleSpecial (std::string const &workspace_name) {
@@ -282,35 +287,6 @@ void Workspaces::loadPersistentWorkspacesFromConfig(Json::Value const &clientsJs
282
287
}
283
288
}
284
289
285
- void Workspaces::loadPersistentWorkspacesFromWorkspaceRules (const Json::Value &clientsJson) {
286
- spdlog::info (" Loading persistent workspaces from Hyprland workspace rules" );
287
-
288
- auto const workspaceRules = gIPC ->getSocket1JsonReply (" workspacerules" );
289
- for (Json::Value const &rule : workspaceRules) {
290
- if (!rule[" workspaceString" ].isString ()) {
291
- spdlog::warn (" Workspace rules: invalid workspaceString, skipping: {}" , rule);
292
- continue ;
293
- }
294
- if (!rule[" persistent" ].asBool ()) {
295
- continue ;
296
- }
297
- auto const &workspace = rule[" workspaceString" ].asString ();
298
- auto const &monitor = rule[" monitor" ].asString ();
299
- // create this workspace persistently if:
300
- // 1. the allOutputs config option is enabled
301
- // 2. the rule's monitor is the current monitor
302
- // 3. no monitor is specified in the rule => assume it needs to be persistent on every monitor
303
- if (allOutputs () || m_bar.output ->name == monitor || monitor.empty ()) {
304
- // => persistent workspace should be shown on this monitor
305
- auto workspaceData = createMonitorWorkspaceData (workspace, m_bar.output ->name );
306
- workspaceData[" persistent-rule" ] = true ;
307
- m_workspacesToCreate.emplace_back (workspaceData, clientsJson);
308
- } else {
309
- m_workspacesToRemove.emplace_back (workspace);
310
- }
311
- }
312
- }
313
-
314
290
void Workspaces::onEvent (const std::string &ev) {
315
291
std::lock_guard<std::mutex> lock (m_mutex);
316
292
std::string eventName (begin (ev), begin (ev) + ev.find_first_of (' >' ));
0 commit comments