Alexays / Waybar

Highly customizable Wayland bar for Sway and Wlroots based compositors. :v: :tada:
MIT License
6.49k stars 702 forks source link

Hyprland: Special workspace switching is wonky #2861

Open Ben9986 opened 8 months ago

Ben9986 commented 8 months ago

I have hyprland/workspaces module loaded in waybar and i have noticed that if i open an empty special workspace and then close it again, the regular workspace with the same number is removed from waybar.

Steps to reproduce: Have hyprland/workspaces loaded into waybar On workspace 1, open workspace special:1 using a defined key bind. Close that special workspace with no windows on it. Notice that the waybar workspaces module is now missing workspace 1.

I have repro'd this issue after running socat - UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock and got this output:

createworkspace>>special:1
activewindow>>,
activewindowv2>>,
activespecial>>special:1,HDMI-A-1
activespecial>>,HDMI-A-1
activewindow>>kitty,nix-shell -p socat
activewindowv2>>3a2f8c0
destroyworkspace>>special:1

To me (not a programmer), it looks like it's because the hyprland socket doesn't report that workspace 1 is focused again after the special is closed. Only reporting the focused window, in my case kitty. I initially thought this was a hyprland issue but after the above steps, switching between regular workspaces never brings back the one that "disappeared" on waybar despite hyprland correctly reporting the workspace switch.

Hope this made sense, if you need any more info/testing I'm happy to help!

zjeffer commented 8 months ago

This is probably caused by this: https://github.com/Alexays/Waybar/pull/2540

@Syndelis

Syndelis commented 8 months ago

Hey there! It's a combination of problems: originally, some Hyprland IPC messages would purposefully not include the special: prefix, which brought previous work on Waybar to strip the prefix at first. This did cause some code not to correctly account for worksace "specialness" when comparing names, including the linked PR.

I'm working on a solution in #2864. Although the first commit already addresses this problem, I'm thinking of implementing a wrapper type for the name attribute so that you can't compare just names (think of Rust enums). I'll see where that gets me.

For the time, could you please try that PR, @Jaques22 ?

Ben9986 commented 8 months ago

Amazing thanks that PR fixes the issues i was having. Special workspaces now show up like i'd expect. Only thing i have noticed is that if i am on workspace 1 and open special:1 then i have two "1"s highlighted in my bar which i guess is technically correct? Though it would be nice to have the option of "special workspace focus overrides regular workspace" if possible but not sure its in the scope of this issue.

Syndelis commented 8 months ago

Amazing thanks that PR fixes the issues i was having. Special workspaces now show up like i'd expect. Only thing i have noticed is that if i am on workspace 1 and open special:1 then i have two "1"s highlighted in my bar which i guess is technically correct? Though it would be nice to have the option of "special workspace focus overrides regular workspace" if possible but not sure its in the scope of this issue.

Oh that's not a problem caused specifically because your special and regular workspaces share the same name, that's just a thing in waybar. If I'm not mistaken either Hyprland doesn't notify when the special is toggled or we are not listening to the right event (can't remember). I'll check later to see which is it and, if the latter, I'll implement it