Skip to content

Add Waybar workspace module with per-workspace window count#6136

Open
sullivan-assie wants to merge 1 commit into
basecamp:masterfrom
sullivan-assie:feat/waybar-workspace-window-count
Open

Add Waybar workspace module with per-workspace window count#6136
sullivan-assie wants to merge 1 commit into
basecamp:masterfrom
sullivan-assie:feat/waybar-workspace-window-count

Conversation

@sullivan-assie

Copy link
Copy Markdown

What

Replaces the default hyprland/workspaces module with a custom Waybar module
that shows each workspace number followed by a superscript badge of its window
count
, highlights the active workspace, and updates instantly via the Hyprland
IPC socket.

▸ 1²   2¹   3   4   5
  • Workspaces with no windows render as a plain number (no badge).
  • At least MIN_WS=5 workspaces are always shown, matching the current
    persistent-workspaces default.
  • Live updates are driven by .socket2.sock events (workspace/window/monitor
    changes) — no polling.

Why

The number badge gives an at-a-glance sense of where your windows are without
opening each workspace, while keeping the bar compact.

Dependencies

None added. Both jq and socat are already declared in
install/omarchy-base.packages, and streaming .socket2.sock through socat
mirrors the existing pattern in bin/omarchy-hyprland-monitor-watch.

Trade-offs / open questions (happy to adjust)

  • Navigation: a Waybar custom module renders a single label, so
    individual workspace numbers are not clickable. Mouse-wheel scroll over the
    module switches workspaces (workspace e-1 / e+1); the native module's
    click-to-activate-a-specific-workspace is not preserved. If keeping per-WS
    click is a requirement, the alternative is the native module with
    window-rewrite (shows per-window app icons instead of a count).
  • Active highlight color is currently hard-coded (#ff3b30). Since a custom
    module can't reference theme CSS colors per-segment via Pango, I kept it
    inline — open to a better theme-aware approach if you have a preferred one.

Testing

Tested on Hyprland (Waybar v0.15.0): badge counts track window open/close/move
across workspaces, the active workspace highlight follows focus, and scroll
switches workspaces.

🤖 Generated with Claude Code

Replace the default hyprland/workspaces module with a custom module that
shows each workspace number followed by a superscript badge of its window
count, highlights the active workspace, and updates live via the Hyprland
IPC socket (socat). Empty/persistent workspaces render without a badge.

Both jq and socat are already in install/omarchy-base.packages, and
streaming .socket2.sock via socat mirrors the existing pattern in
bin/omarchy-hyprland-monitor-watch, so no new dependencies are introduced.
Copilot AI review requested due to automatic review settings June 25, 2026 07:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces Waybar’s built-in hyprland/workspaces module with a custom script-backed module that renders workspace numbers with a superscript window-count badge, and refreshes on Hyprland .socket2.sock events (no polling).

Changes:

  • Add default/waybar/workspace-windows.sh to render workspaces + per-workspace window counts and repaint on relevant Hyprland IPC events.
  • Update config/waybar/config.jsonc to swap hyprland/workspaces for custom/workspace-windows, including scroll-to-switch workspace bindings.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
default/waybar/workspace-windows.sh New Waybar custom-module script that formats workspace labels with superscript window-count badges and listens to Hyprland socket events for live updates.
config/waybar/config.jsonc Switches Waybar’s left modules to use the new custom/workspace-windows module and configures execution/scroll behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# Map "id -> window count" for normal (id >= 1) workspaces.
declare -A counts=()
while read -r id win; do
[[ "$id" =~ ^[0-9]+$ ]] && (( id >= 1 )) && counts[$id]=$win

# Show up to the highest populated/active workspace, but at least MIN_WS.
for id in "${!counts[@]}"; do (( id > max )) && max=$id; done
[[ "$active" =~ ^[0-9]+$ ]] && (( active > max )) && max=$active
c=${counts[$ws]:-0}
label="$ws"
(( c > 0 )) && label+="$(to_super "$c")"
if [[ "$ws" == "$active" ]]; then
@sullivan-assie

Copy link
Copy Markdown
Author

Here's the module in action — workspace numbers with a superscript window-count badge, active workspace highlighted:

Waybar workspace window count

1¹ 2¹ 3³ 4² 5 (workspace 5 active).

@atomicol

Copy link
Copy Markdown

I was thinking about this yesterday when I lost track of my windows. Definitely needs a theming approach though, since hard coding those styles will not appeal to everyone.

@brink-lab

Copy link
Copy Markdown
Contributor

A kind heads-up :)

The upcoming Omarchy 4 release moves away from Waybar in favour of a new quickshell based solution.
So if you have the courage you can consider to port it over already now - or wait until Omarchy 4 has been released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants