Skip to content

Commit

Permalink
add only-populated option to niri/workspaces
Browse files Browse the repository at this point in the history
when set to true, only workspaces which contain windows will be drawn.
(the active one will always be drawn)
  • Loading branch information
hansp27 committed Feb 6, 2025
1 parent c32d5e3 commit a9b74c8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions man/waybar-niri-workspaces.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ Addressed by *niri/workspaces*
default: false ++
If set to true, only the active or focused workspace will be shown.

*only-populated*: ++
typeof: bool ++
default: false ++
If set to true, only workspaces that contain windows will be shown.

*on-update*: ++
typeof: string ++
Command to execute when the module is updated.
Expand Down
2 changes: 2 additions & 0 deletions src/modules/niri/workspaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ void Workspaces::doUpdate() {
auto ipcLock = gIPC->lockData();

const auto alloutputs = config_["all-outputs"].asBool();
const auto onlypop= config_["only-populated"].asBool();
std::vector<Json::Value> my_workspaces;
const auto &workspaces = gIPC->workspaces();
std::copy_if(workspaces.cbegin(), workspaces.cend(), std::back_inserter(my_workspaces),
[&](const auto &ws) {
if (onlypop && ws["active_window_id"].isNull() && !ws["is_active"].asBool()) return false;
if (alloutputs) return true;
return ws["output"].asString() == bar_.output->name;
});
Expand Down

0 comments on commit a9b74c8

Please sign in to comment.