Alexays / Waybar

Highly customizable Wayland bar for Sway and Wlroots based compositors. :v: :tada:
MIT License
6.68k stars 709 forks source link

[Feature Request] Niri per-workspace taskbar feature #3745

Open sszark opened 1 week ago

sszark commented 1 week ago

Some old desktops that predates Wayland, has a feature to isolate windows to their own workspace. This is very useful when working with multiple workspaces, as you only need to see and interface with the relevant windows in scope. As opposed to displaying everything. Which is the current behavior of wlr/taskbar. Since it's limited by the generic foreign-toplevel-manager protocol.

Niri associates windows with their respective workspace. Which can be queried through their IPC interface.

Window ID 3: (focused)
  Title: "a"
  App ID: "foot"
  Workspace ID: 1

I suggest creating a feature that would allow for this kind of taskbar isolation for windows.
Below is an example of per-workspace window filtering:

#!/bin/sh
active_workspace="$(niri msg -j workspaces | jq ".[] | select(.is_focused == true) | .id")"
filtered_windows="$(niri msg -j windows | jq ".[] | select(.workspace_id == $active_workspace)")"
echo "$filtered_windows"
# before
{ "id": 3, "title": "a", "app_id": "foot", "workspace_id": 1, "is_focused": true }
{ "id": 5, "title": "b", "app_id": "foot", "workspace_id": 3, "is_focused": false }
{ "id": 1, "title": "c", "app_id": "foot", "workspace_id": 1, "is_focused": false }
{ "id": 2, "title": "d", "app_id": "foot", "workspace_id": 1, "is_focused": false }
{ "id": 4, "title": "e", "app_id": "foot", "workspace_id": 2, "is_focused": false }

# after (active: 1)
{ "id": 3, "title": "a", "app_id": "foot", "workspace_id": 1, "is_focused": true }
{ "id": 1, "title": "c", "app_id": "foot", "workspace_id": 1, "is_focused": false }
{ "id": 2, "title": "d", "app_id": "foot", "workspace_id": 1, "is_focused": false }
YaLTeR commented 1 week ago

As far as I understand, windows are usually included in the compositor/workspaces module (i.e. hyprland/workspaces). (I didn't implement it for my initial niri modules impl just because it was a chunk of extra work.)