README.md (2483B)
1 # niri-workspaces-rs 2 3 A fast, event-driven workspace indicator for [Waybar](https://github.com/Alexays/Waybar) and [niri](https://github.com/YaLTeR/niri). 4 5 <img width="2880" height="1800" alt="image" src="https://github.com/user-attachments/assets/5b1debef-c18d-4ae9-9a82-5655dd4fc913" /> 6 7 8 https://github.com/user-attachments/assets/7fb1fea8-ff79-489a-80f3-63fb1a20cf32 9 10 11 ## Features 12 13 - **Visual bars instead of numbers** — each window is rendered as a colored bar. 14 - **Event-driven daemon mode** — keeps a persistent niri socket connection and emits JSON updates only when workspace/window state changes. 15 - **App-aware coloring** — built-in colors for Chrome (red), Firefox, Discord/Vesktop, Spotify, Todoist, Gmail, and terminals. 16 - **Terminal app detection via `/proc`** — detects `jcode`, Claude, Codex, and Neovim/Vim running inside terminal windows. 17 - **Terminal support** — works with Alacritty, Kitty, Ghostty, Foot, and Footclient. 18 - **Focus semantics** — uses `█` for the focused window, `▌` for the active window on an unfocused workspace, and `|` for other windows. 19 - **tmux hinting** — uses `¦` for non-focused tmux windows. 20 - **Cleaner empty workspace handling** — unfocused empty workspaces are hidden; a focused empty workspace is shown as a dim `·`. 21 - **Named workspace support** — shows the custom workspace name when that workspace is focused; tooltips include only non-empty workspaces. 22 - **Safer terminal PID detection** — skips `/proc` descendant inference for shared terminal PIDs in cases that can otherwise cause false positives. 23 24 ## Benchmarks 25 26 | Metric | Value | 27 |--------|-------| 28 | Memory | 2.5 MB RSS | 29 | CPU per update | ~1.1ms | 30 | 80 rapid switches | ~90ms total CPU | 31 32 ### Comparison 33 34 | Approach | CPU per update | 35 |----------|---------------| 36 | Bash script | ~340ms | 37 | Rust + signal | ~12-14ms | 38 | Rust daemon | **~1.1ms** | 39 40 The daemon is **~10-12x faster** than the signal-based approach and **~300x faster** than the original bash script. 41 42 ## Installation 43 44 ```bash 45 cargo build --release 46 cp target/release/niri-workspaces ~/.config/waybar/ 47 ``` 48 49 If Waybar is already running, restart Waybar or reload the module so the new binary is picked up. 50 51 ## Waybar Configuration 52 53 ```json 54 "custom/workspaces": { 55 "exec": "~/.config/waybar/niri-workspaces", 56 "return-type": "json", 57 "format": "{}" 58 } 59 ``` 60 61 No `interval` or `signal` is needed — the daemon outputs JSON whenever relevant niri events occur. 62 63 ## License 64 65 MIT