Option to show number of indows on the workspace
This seems probably like a strange request, but some workspace/app combinations work better in floating mode. However in those cases it would be nice to know of windows hidden behind others. Would this be easy to implement?
Using custom in combination with swaymsg -t get_tree | jq somefilter seems somewhat wastefull
Update 2024-08-24
Made a PR with cpp windowcount module:
- https://github.com/Alexays/Waybar/pull/3544
Mainly wanted "separate-outputs", i.e. windows count should be specific to each monitor.
Original
I was able to achieve something similar for Hyprland workspaces with a custom module that listens to events - documentation here:
- https://wiki.hyprland.org/IPC/
For example, in ~/.config/waybar/scripts/hyprland_clients.sh:
#!/bin/sh
: "${XDG_RUNTIME_DIR:?Environment variable XDG_RUNTIME_DIR not set}"
: "${HYPRLAND_INSTANCE_SIGNATURE:?Environment variable HYPRLAND_INSTANCE_SIGNATURE not set}"
handle() {
case "$1" in
workspace* | focusedmon* | openwindow* | closewindow* | movewindow*)
update_active_clients
;;
esac
}
update_active_clients() {
active_clients=$(hyprctl activeworkspace -j | jq -r .windows)
echo "$active_clients"
}
# Initial update
update_active_clients
# Listen to events and handle them
socat -U - UNIX-CONNECT:"$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | while IFS= read -r line; do
handle "$line"
done
and then in ~/.config/waybar/config.jsonc:
// ...
"modules-left": [
"custom/hyprland_clients",
"hyprland/workspaces"
],
// ...
"custom/hyprland_clients": {
"exec": "~/.config/waybar/scripts/hyprland_clients.sh",
"format": "[{}]"
},
// ...
One caveat is that on a multi-monitor setup, it will still show the count for the currently active/focused workspace of the focused monitor, instead of the visible workspace of each individual monitor separately.
Would be nice to see this supported natively. Feature was also requested in this Reddit post.