Skip to content

Commit

Permalink
fixed bugs, updated manpage
Browse files Browse the repository at this point in the history
  • Loading branch information
zjeffer committed Sep 3, 2023
1 parent 4e11b2f commit 9fb7696
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
8 changes: 5 additions & 3 deletions man/waybar-hyprland-workspaces.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Addressed by *hyprland/workspaces*
*show-special*: ++
typeof: bool ++
default: false ++
If set to true special workspaces will be shown.
If set to true, special workspaces will be shown.

*all-outputs*: ++
typeof: bool ++
Expand All @@ -48,10 +48,11 @@ Addressed by *hyprland/workspaces*

Additional to workspace name matching, the following *format-icons* can be set.

- *default*: Will be shown, when no string match is found.
- *default*: Will be shown, when no string match is found and none of the below conditions have defined icons.
- *active*: Will be shown, when workspace is active
- *special*: Will be shown on non-active special workspaces
- *empty*: Will be shown on empty persistent workspaces
- *empty*: Will be shown on non-active, non-special empty persistent workspaces
- *visible*: Will be shown on workspaces that are visible but not active. For example: this is useful if you want your visible workspaces on other monitors to have the same look as active.
- *persistent*: Will be shown on non-empty persistent workspaces

# EXAMPLES
Expand Down Expand Up @@ -100,6 +101,7 @@ Additional to workspace name matching, the following *format-icons* can be set.
- *#workspaces button*
- *#workspaces button.active*
- *#workspaces button.empty*
- *#workspaces button.visible*
- *#workspaces button.persistent*
- *#workspaces button.special*
- *#workspaces button.urgent*
42 changes: 19 additions & 23 deletions src/modules/hyprland/workspaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,37 +79,33 @@ auto Workspaces::update() -> void {

workspaces_to_create_.clear();

// get all active workspaces
auto monitors = gIPC->getSocket1JsonReply("monitors");
std::vector<std::string> active_ws;
std::vector<std::string> visible_workspaces;
for (Json::Value &monitor : monitors) {
auto ws = monitor["activeWorkspace"];
if (ws.isObject() && (ws["name"].isString())) {
active_ws.push_back(ws["name"].asString());
visible_workspaces.push_back(ws["name"].asString());
}
}

for (auto &workspace : workspaces_) {
// active
workspace->set_active(workspace->name() == active_workspace_name_);
if (workspace->name() == active_workspace_name_ && workspace.get()->is_urgent()) {
// disable urgency if workspace is active
if (workspace->name() == active_workspace_name_ && workspace->is_urgent()) {
workspace->set_urgent(false);
}

// visible
workspace->set_visible(std::find(visible_workspaces.begin(), visible_workspaces.end(),
workspace->name()) != visible_workspaces.end());

// set workspace icon
std::string &workspace_icon = icons_map_[""];
if (with_icon_) {
workspace_icon = workspace->select_icon(icons_map_);
}
if (std::find_if(active_ws.begin(), active_ws.end(), [&](const std::string &ws) {
return ws == workspace->name();
}) != active_ws.end()) {
spdlog::info("Workspace {} is visible", workspace->name());
workspace->set_visible(true);
} else {
if (workspace->is_visible())
{
spdlog::info("Workspace {} is not visible", workspace->name());
}
workspace->set_visible(false);

}
workspace->update(format_, workspace_icon);
}
AModule::update();
Expand Down Expand Up @@ -448,20 +444,20 @@ std::string &Workspace::select_icon(std::map<std::string, std::string> &icons_ma
return named_icon_it->second;
}

if (is_empty()) {
auto empty_icon_it = icons_map.find("empty");
if (empty_icon_it != icons_map.end()) {
return empty_icon_it->second;
}
}

if (is_visible()) {
auto visible_icon_it = icons_map.find("visible");
if (visible_icon_it != icons_map.end()) {
return visible_icon_it->second;
}
}

if (is_empty()) {
auto empty_icon_it = icons_map.find("empty");
if (empty_icon_it != icons_map.end()) {
return empty_icon_it->second;
}
}

if (is_persistent()) {
auto persistent_icon_it = icons_map.find("persistent");
if (persistent_icon_it != icons_map.end()) {
Expand Down

0 comments on commit 9fb7696

Please sign in to comment.