MCPcopy Create free account
hub / github.com/Alexays/Waybar / initializeWorkspaces

Method initializeWorkspaces

src/modules/hyprland/workspaces.cpp:180–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178}
179
180void Workspaces::initializeWorkspaces() {
181 spdlog::debug("Initializing workspaces");
182
183 // if the workspace rules changed since last initialization, make sure we reset everything:
184 for (auto& workspace : m_workspaces) {
185 m_workspacesToRemove.push_back(std::to_string(workspace->id()));
186 }
187
188 // get all current workspaces
189 auto const workspacesJson = m_ipc.getSocket1JsonReply("workspaces");
190 auto const clientsJson = m_ipc.getSocket1JsonReply("clients");
191
192 for (Json::Value workspaceJson : workspacesJson) {
193 std::string workspaceName = workspaceJson["name"].asString();
194 if ((allOutputs() || m_bar.output->name == workspaceJson["monitor"].asString()) &&
195 (!workspaceName.starts_with("special") || showSpecial()) &&
196 !isWorkspaceIgnored(workspaceName)) {
197 m_workspacesToCreate.emplace_back(workspaceJson, clientsJson);
198 } else {
199 extendOrphans(workspaceJson["id"].asInt(), clientsJson);
200 }
201 }
202
203 spdlog::debug("Initializing persistent workspaces");
204 if (m_persistentWorkspaceConfig.isObject()) {
205 // a persistent workspace config is defined, so use that instead of workspace rules
206 loadPersistentWorkspacesFromConfig(clientsJson);
207 }
208 // load Hyprland's workspace rules
209 loadPersistentWorkspacesFromWorkspaceRules(clientsJson);
210}
211
212bool isDoubleSpecial(std::string const& workspace_name) {
213 // Hyprland's IPC sometimes reports the creation of workspaces strangely named

Callers

nothing calls this directly

Calls 3

to_stringFunction · 0.85
getSocket1JsonReplyMethod · 0.80
idMethod · 0.45

Tested by

no test coverage detected