@@ -185,10 +185,17 @@ void Workspaces::initializeWorkspaces() {
185
185
186
186
// get all current workspaces
187
187
auto const workspacesJson = m_ipc.getSocket1JsonReply (" workspaces" );
188
+ auto const workspacerulesJson = m_ipc.getSocket1JsonReply (" workspacerules" );
188
189
auto const clientsJson = m_ipc.getSocket1JsonReply (" clients" );
189
190
190
191
for (Json::Value workspaceJson : workspacesJson) {
191
192
std::string workspaceName = workspaceJson[" name" ].asString ();
193
+ for (Json::Value workspaceRule: workspacerulesJson) {
194
+ if (workspaceJson[" id" ].asString () == workspaceRule[" workspaceString" ].asString () &&
195
+ workspaceRule[" persistent" ] == true ) {
196
+ workspaceJson[" persistent-rule" ] = true ;
197
+ }
198
+ }
192
199
if ((allOutputs () || m_bar.output ->name == workspaceJson[" monitor" ].asString ()) &&
193
200
(!workspaceName.starts_with (" special" ) || showSpecial ()) &&
194
201
!isWorkspaceIgnored (workspaceName)) {
@@ -198,13 +205,11 @@ void Workspaces::initializeWorkspaces() {
198
205
}
199
206
}
200
207
201
- spdlog::debug (" Initializing persistent workspaces" );
208
+ spdlog::debug (" Initializing persistent workspaces from config " );
202
209
if (m_persistentWorkspaceConfig.isObject ()) {
203
210
// a persistent workspace config is defined, so use that instead of workspace rules
204
211
loadPersistentWorkspacesFromConfig (clientsJson);
205
212
}
206
- // load Hyprland's workspace rules
207
- loadPersistentWorkspacesFromWorkspaceRules (clientsJson);
208
213
}
209
214
210
215
bool isDoubleSpecial (std::string const &workspace_name) {
@@ -281,36 +286,6 @@ void Workspaces::loadPersistentWorkspacesFromConfig(Json::Value const &clientsJs
281
286
}
282
287
}
283
288
284
- void Workspaces::loadPersistentWorkspacesFromWorkspaceRules (const Json::Value &clientsJson) {
285
- spdlog::info (" Loading persistent workspaces from Hyprland workspace rules" );
286
-
287
- auto const workspaceRules = m_ipc.getSocket1JsonReply (" workspacerules" );
288
- for (Json::Value const &rule : workspaceRules) {
289
- if (!rule[" workspaceString" ].isString ()) {
290
- spdlog::warn (" Workspace rules: invalid workspaceString, skipping: {}" , rule);
291
- continue ;
292
- }
293
- if (!rule[" persistent" ].asBool ()) {
294
- continue ;
295
- }
296
- auto const &workspace = rule.isMember (" defaultName" ) ? rule[" defaultName" ].asString ()
297
- : 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
289
void Workspaces::onEvent (const std::string &ev) {
315
290
std::lock_guard<std::mutex> lock (m_mutex);
316
291
std::string eventName (begin (ev), begin (ev) + ev.find_first_of (' >' ));
0 commit comments