Waybar icon indicating copy to clipboard operation
Waybar copied to clipboard

Add niri/workspaces, niri/window, niri/language

Open YaLTeR opened this issue 1 year ago • 1 comments
trafficstars

I am working on an event stream IPC for the niri Wayland compositor, which is intended for bar modules and the like. To test out the design, I implemented Waybar modules for workspaces, focused window and language.

This PR is a Draft until I merge the niri PR (in a few days).

I followed the existing modules for Sway and Hyprland in my niri implementation, though with some differences. Unlike Sway and Hyprland, the niri event stream IPC starts by sending the complete current state, so Waybar doesn't need to query it from other IPC calls. This, however, makes it more convenient to track the state in the IPC class directly, so that modules registering after the initial event burst can still access the current state.

The modules mostly support a similar feature set to the Sway and Hyprland ones, though one notable omission is the window list built into the workspaces module. (All data is there, just didn't get around to it.)

Also, in the workspaces module, configurable sorting order and persistent workspaces are omitted because they don't really make sense for niri's dynamic workspace system.

I documented all supported functionality in the .scd man pages.

YaLTeR avatar Aug 30 '24 18:08 YaLTeR

The niri PR is merged, so this is ready for review.

YaLTeR avatar Sep 02 '24 06:09 YaLTeR

Done

YaLTeR avatar Sep 13 '24 07:09 YaLTeR

LGTM thx for this nice addition :)

Alexays avatar Sep 13 '24 07:09 Alexays

@YaLTeR Currently I'm using both Hyprland and Niri with the same Waybar config. If I'm on Niri, Hyprland modules will be disabled

[2024-12-23 01:20:10.140] [info] Using configuration file /home/thang/.config/waybar/config
[2024-12-23 01:20:10.144] [info] Discovered appearance 'dark'
[2024-12-23 01:20:10.144] [info] Using CSS file /home/thang/.config/waybar/style.css
basic_string::_M_create
[2024-12-23 01:20:10.150] [warning] Hyprland is not running, Hyprland IPC will not be available.
[2024-12-23 01:20:10.150] [warning] module hyprland/workspaces: Disabling module "hyprland/workspaces", Hyprland IPC: HYPRLAND_INSTANCE_SIGNATURE was not set! (Is Hyprland running?)
[2024-12-23 01:20:10.150] [info] Niri IPC starting
[2024-12-23 01:20:10.150] [warning] module hyprland/window: Disabling module "hyprland/window", Hyprland IPC: HYPRLAND_INSTANCE_SIGNATURE was not set! (Is Hyprland running?)
[2024-12-23 01:20:10.205] [info] Bar configured (width: 1646, height: 40) for output: eDP-1

If I'm on Hyprland, It correctly detects that Niri is not running but Niri modules won't be disabled

[2024-12-23 01:19:13.784] [info] Using configuration file /home/thang/.config/waybar/config
[2024-12-23 01:19:13.788] [info] Discovered appearance 'dark'
[2024-12-23 01:19:13.788] [info] Using CSS file /home/thang/.config/waybar/style.css
[2024-12-23 01:19:13.794] [info] Hyprland IPC starting
[2024-12-23 01:19:13.795] [info] Loading persistent workspaces from Waybar config
[2024-12-23 01:19:13.795] [info] Loading persistent workspaces from Hyprland workspace rules
[2024-12-23 01:19:13.795] [warning] Niri is not running, niri IPC will not be available.
[2024-12-23 01:19:13.859] [info] Bar configured (width: 1440, height: 40) for output: eDP-1

I hope you can take a look and add implementation to disable the module when Niri is not running

thang-qt avatar Dec 22 '24 18:12 thang-qt