feat (niri/workspaces): add dynamic window icons to workspaces matching hyprland/workspaces #4396
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR brings Hyprland-style window icon “rewrite” functionality to the
niri/workspacesmodule. It adds a{windows}format token and opt‑in configuration keys to map window metadata (e.g.,app_idandtitle) to icons/text via regex rules, then renders them per workspace with a configurable separator.The feature is fully backward compatible: if you don’t configure the new keys, the module behaves as before.
Motivation
Waybar’s Hyprland module supports window icon rewrite rules that many users rely on for consistent workspace indicators. This PR provides feature parity for
niri/workspaces, enabling unified configs across compositors.Changes
include/modules/niri/workspaces.hppsrc/modules/niri/workspaces.cppman/waybar-niri-workspaces.5.scd(documents{windows},window-rewrite,window-rewrite-default,format-window-separator)resources/config.jsonc(shows how to configure rewrite rules)New configuration
format: now supports{windows}to render the per‑workspace window representations.window-rewrite(object): ordered regex map; keys are patterns applied toapp_idandtitle, values are the replacement strings (usually glyphs or short names).app_id<regex>,title<regex>window-rewrite-default(string): fallback text/icon when no rule matches (default:?).format-window-separator(string): string inserted between window representations (default: single space).Example (JSONC)
Note: Icon glyphs require a compatible font (e.g., Nerd Fonts).
Behavior
ws["windows"]when present; otherwise filters from the global windows list by workspace association).window-rewriterules (regex againstapp_idandtitle) and uses the first match.window-rewrite-defaultwhen no rule matches.format-window-separatorand injects into{windows}.Backward compatibility
Documentation
niri/workspacesman page has been updated to document:{windows}token semanticswindow-rewrite,window-rewrite-default, andformat-window-separatorapp_id<regex>andtitle<regex>) and precedenceTest plan
window-rewriterules above.●or?).Notes for reviewers
Checklist
ws["windows"]and a global windows fallback.tested locally with this example -