Environment
- Waybar 0.15.x
- niri compositor
Background
niri always maintains at least one extra empty workspace beyond the last used one (this is intentional niri behavior by design). As a result, the niri/workspaces module always renders at least one button with the button.empty class.
Problem
There is currently no way to hide empty workspaces in the niri/workspaces module. Attempting to hide them via CSS (opacity: 0, min-width: 0, padding: 0, etc.) does not fully work because the GTK Box container still preserves spacing between child elements, leaving a visible gap in the bar.
Requested change
Add a hide-empty boolean option (default: false) to the niri/workspaces module that completely removes empty workspace buttons from the widget tree, rather than just styling them.
Example config
Workaround
Currently the only reliable workaround is a custom polling script that filters out empty workspaces and outputs Pango markup as a single custom/ module. This works visually but loses per-workspace click support, which is only available in the native module.
Like that:
#!/bin/bash
niri msg --json workspaces | jq -c '
sort_by(.idx) |
map(select(.is_focused or (.active_window_id != null))) |
{
text: (map(
if .is_focused then
"<span background=\"#dc312e\" color=\"#ffffff\"> \(.name) </span>"
else
"<span color=\"#dddddd\"> \(.name) </span>"
end
) | join("")),
class: "niri-workspaces"
}
```'
Environment
Background
niri always maintains at least one extra empty workspace beyond the last used one (this is intentional niri behavior by design). As a result, the
niri/workspacesmodule always renders at least one button with thebutton.emptyclass.Problem
There is currently no way to hide empty workspaces in the
niri/workspacesmodule. Attempting to hide them via CSS (opacity: 0,min-width: 0,padding: 0, etc.) does not fully work because the GTK Box container still preserves spacing between child elements, leaving a visible gap in the bar.Requested change
Add a
hide-emptyboolean option (default:false) to theniri/workspacesmodule that completely removes empty workspace buttons from the widget tree, rather than just styling them.Example config
Workaround
Currently the only reliable workaround is a custom polling script that filters out empty workspaces and outputs Pango markup as a single
custom/module. This works visually but loses per-workspace click support, which is only available in the native module.Like that: