Skip to content

Add niri-taskbar widget for vibepanel#96

Merged
prankstr merged 4 commits intoprankstr:mainfrom
Minimalon:add-niri-taskbar-widget
Apr 8, 2026
Merged

Add niri-taskbar widget for vibepanel#96
prankstr merged 4 commits intoprankstr:mainfrom
Minimalon:add-niri-taskbar-widget

Conversation

@Minimalon
Copy link
Copy Markdown
Contributor

This commit adds a taskbar widget that displays all open windows on the monitor, similar to niri-taskbar for Waybar.

Features:

  • Display all open windows as clickable buttons
  • Show app icons and window titles
  • Highlight focused window
  • Click to focus window
  • Filter windows by output/monitor
  • Configurable max number of windows

New files:

  • src/services/window_list.rs: Service for window list monitoring
  • src/widgets/niri_taskbar.rs: Taskbar widget implementation

Modified files:

  • src/services/compositor/types.rs: Add Window and WindowListSnapshot types
  • src/services/compositor/niri.rs: Implement list_windows() and focus_window()
  • src/services/compositor/manager.rs: Add window list methods
  • src/services.rs: Add window_list module
  • src/styles.rs: Add niri-taskbar CSS classes
  • src/widgets/mod.rs: Register niri_taskbar widget

Usage in config.toml:
[[widgets]]
name = niri_taskbar
type = niri_taskbar

[widgets.niri_taskbar]
show_titles = true
show_icons = true
max_windows = 10
filter_by_output = true

@prankstr
Copy link
Copy Markdown
Owner

prankstr commented Apr 6, 2026

Thank you for the contribution! There is a couple of things I'd like to sort out before being comfortable with bringing this into the codebase though.

First of all, the WindowListService polls for windows every second, this seems unnecessary and could easily be event driven with a callback that would trigger the window fetching on changes instead. Similar to how the WindowTitleService works.

Secondly, the widget is called niri-taskbar but the getting the window list is abstracted behind compositorManager and I know for sure that at least Hyprland could implement list_windows() as well so I think it would make more sense to name the widget just taskbar even if we just support Niri initially.

Lastly, I'd like the config options to be singular instead of plural, i.e show_icon instead of show_icons. I get the reasoning but for consistency I think singular is better. And show_title should probably be false by default instead of true? I feel like most taskbar are icons only by default.

Let me know if you want assistance with any of this.

- Rename niri_taskbar widget to taskbar for compositor-agnostic naming
- Make WindowListService event-driven via callback instead of polling
- Change config options to singular: show_title, show_icon
- Set show_title default to false (icons only by default)
- Add WindowListCallback type and set_window_list_callback to trait
- Implement event-driven window list updates in NiriBackend
- Add register_window_list_callback to CompositorManager

All 350 tests pass.
@Minimalon Minimalon force-pushed the add-niri-taskbar-widget branch from 22b3337 to d08a123 Compare April 6, 2026 14:22
@Minimalon
Copy link
Copy Markdown
Contributor Author

Add new commit

prankstr added 2 commits April 7, 2026 12:37
- Sort taskbar buttons by workspace index, layout position, then window
  ID to match niri's visual window order
- Handle WindowLayoutsChanged events for live reorder when moving columns
- Fix JSON parsing for WindowLayoutsChanged (Vec of tuples, not object)
- Remove manual spacers that caused double spacing with existing CSS gap
- Add hover/active CSS for taskbar buttons using padding+negative-margin
- Update window title labels on state change without full rebuild
- Remove stale "Niri" references from doc comments
- icon_size option (default: theme pixmap_icon_size, min 8px, max bar-constrained)
- show_active option (default: true) to toggle focused-window highlight
- Per-button CssProvider with proportional padding (icon_size/4, min 3px)
- Border radius follows widget_radius_percent from theme
- Icon shrinks only when needed to fit within bar constraints
@prankstr
Copy link
Copy Markdown
Owner

prankstr commented Apr 7, 2026

Thanks :) I went ahead and pushed two commits on top of yours.

The first one fixes a few things that were bugging me. Window ordering is now deterministic, buttons are sorted by workspace index, then layout position, then window ID so they match niri's visual order, same as niri-taskbar. I also fixed so icons reorder live when you move windows around and there's now basic hover/active CSS for the buttons.

The second commit adds icon_size and show_active as config options. icon_size defaults to the theme's pixmap_icon_size and scales with bar size. show_active lets you turn off the focused window highlight if you don't want it.

… multi-monitor sorting

- Add workspace and output separators with distinct visual styles
- Fix focused window tracking (clear stale is_focused on new focus)
- Smart max_windows: swap focused window into last visible slot
- Simplify spacing by eliminating negative margins
- Extract TaskbarLayout struct, shared CssProvider, CONTENT_PADDING_X
- Sort windows by output, workspace index, layout position, then ID
- Trigger window list callback on workspace changes
@prankstr prankstr merged commit 9accd0c into prankstr:main Apr 8, 2026
3 checks passed
@prankstr
Copy link
Copy Markdown
Owner

prankstr commented Apr 8, 2026

Pushed one more commit on top that addresses remaining rough edges:

  • Optional workspace and output separators
  • Fixed a bug where is_focused wasn't cleared on other windows when a new window gets focus
  • max_windows now swaps the focused window into the last visible slot so it's never cut off
  • Window list callback now also fires on workspace changes

I'm happy with where this is at now and will merge it. Thanks again for the contribution!

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.

2 participants