Waybar
Waybar copied to clipboard
[wlr/workspaces] Feature request: Persistent workspaces
Currently, there is no option to have persistent workspaces on wlr/workspaces, only showing workspaces that have window or windows in them. This just hurts ricing and usability on anything other than sway. I have not found an answer as to why this isn't possible.
This would be a great addition to the module.
Any update on this?
This would be a nice feature to have. If you have three occupied workspaces and switch to, for example number 6. It looks like you are on workspace 4 due to the fact that it just add an icon to the right of the already occupied ones. Also on Hyprland once you switch to an empty workspace; and try to switch to another empty one - the bar displays like a workspace icon momentarily (flashes on and off) next to the empty one. I think I did not explain it pretty well :)
@Alexays
+1 this would be very useful for hyprland. seems https://github.com/Alexays/Waybar/blob/master/src/modules/sway/workspaces.cpp#L77-L114 is the related code for sway workspaces. not sure if there are some technical challenges for wlr though.
+1 this would be very useful for hyprland. seems https://github.com/Alexays/Waybar/blob/master/src/modules/sway/workspaces.cpp#L77-L114 is the related code for sway workspaces. not sure if there are some technical challenges for wlr though.
I have found a way to show all workspaces using wlr/workspaces and the waybar-hyprland fork. Basically, it would silently open a terminal without actually showing it, making the workspace visible on waybar since waybar only shows workspaces that have apps open on. I will share this in a gist later.
@Spaxly Hi, I'd love to see this solution!
@Spaxly Hi, I'd love to see this solution!
# Global persistent workspace rules
windowrule=float,title:^PERSISTENT_WORKSPACE.*$
windowrule=nofocus,title:^PERSISTENT_WORKSPACE.*$
windowrule=noblur,title:^PERSISTENT_WORKSPACE.*$
windowrule=size 0 0,title:^PERSISTENT_WORKSPACE.*$
windowrule=move 0 0,title:^PERSISTENT_WORKSPACE.*$
windowrule=opacity 0,title:^PERSISTENT_WORKSPACE.*$
# Individual persistent workspace rules
windowrule=workspace 1,title:^(PERSISTENT_WORKSPACE_1)$
windowrule=workspace 2,title:^(PERSISTENT_WORKSPACE_2)$
windowrule=workspace 3,title:^(PERSISTENT_WORKSPACE_3)$
windowrule=workspace 4,title:^(PERSISTENT_WORKSPACE_4)$
windowrule=workspace 5,title:^(PERSISTENT_WORKSPACE_5)$
# Exec commands to keep each workspace persistent
exec-once=alacritty -t PERSISTENT_WORKSPACE_1 &
exec-once=alacritty -t PERSISTENT_WORKSPACE_2 &
exec-once=alacritty -t PERSISTENT_WORKSPACE_3 &
exec-once=alacritty -t PERSISTENT_WORKSPACE_4 &
exec-once=alacritty -t PERSISTENT_WORKSPACE_5 &
Add the above to your hyprland.conf, if you don't use alacritty, change the terminal. That is what I use for persistent workspaces.
@Spaxly That's horrific but I guess it kind of works lol
The current issue I have is that there is a tiny window in the top left corner of every monitor, which also moves when I switch to a different workspace. Do you also have this problem?
@Spaxly That's horrific but I guess it kind of works lol
The current issue I have is that there is a tiny window in the top left corner of every monitor, which also moves when I switch to a different workspace. Do you also have this problem?
Ik, but that was only solution. Also, I don't have the problem you are talking about.
@Spaxly Hi, I'd love to see this solution!
# Global persistent workspace rules windowrule=float,title:^PERSISTENT_WORKSPACE.*$ windowrule=nofocus,title:^PERSISTENT_WORKSPACE.*$ windowrule=noblur,title:^PERSISTENT_WORKSPACE.*$ windowrule=size 0 0,title:^PERSISTENT_WORKSPACE.*$ windowrule=move 0 0,title:^PERSISTENT_WORKSPACE.*$ windowrule=opacity 0,title:^PERSISTENT_WORKSPACE.*$ # Individual persistent workspace rules windowrule=workspace 1,title:^(PERSISTENT_WORKSPACE_1)$ windowrule=workspace 2,title:^(PERSISTENT_WORKSPACE_2)$ windowrule=workspace 3,title:^(PERSISTENT_WORKSPACE_3)$ windowrule=workspace 4,title:^(PERSISTENT_WORKSPACE_4)$ windowrule=workspace 5,title:^(PERSISTENT_WORKSPACE_5)$ # Exec commands to keep each workspace persistent exec-once=alacritty -t PERSISTENT_WORKSPACE_1 & exec-once=alacritty -t PERSISTENT_WORKSPACE_2 & exec-once=alacritty -t PERSISTENT_WORKSPACE_3 & exec-once=alacritty -t PERSISTENT_WORKSPACE_4 & exec-once=alacritty -t PERSISTENT_WORKSPACE_5 &
Add the above to your hyprland.conf, if you don't use alacritty, change the terminal. That is what I use for persistent workspaces.
I use this solution, though, I have a dual monitor setup and somehow when I turn the DPMS of both monitors off, and on again, the workspace of the secondary monitor gets added to my first monitor and then my secondary monitor gets a new workspace that is workspace-number+1
.
Also after DPMS is turned on again, the focus of the workspace is switched somehow.
Eh, let's hope that one day, there will be a better solution.
Update: I fixed my described issue by setting:
monitor=DP-2,2560x1440@60,1920x0,1
workspace=DP-2,1
workspace=DP-2,2
workspace=DP-2,3
workspace=DP-2,4
workspace=DP-2,5
workspace=DP-2,6
workspace=DP-2,7
workspace=DP-2,8
workspace=DP-2,9
workspace=DP-2,10
monitor=DP-3,1920x1080@60,0x0,1
workspace=DP-3,11
namely, by specifying which workspace should stay on which monitor.
The workspace
settings from 1-10 for DP-2
aren't really needed.
Also, when waking up from DPMS and unlocking, Hyprland goes to an arbitrary workspace.
I also fixed that by adding hyprctl dispatch workspace 1
to my afk
script:
#!/bin/zsh
sleep 1;
hyprctl dispatch dpms off;
swaylock -c 000000;
hyprctl dispatch dpms on;
hyprctl dispatch workspace 1;
Another thing is that when starting Hyprland, it starts in an arbitrary workspace between 1-10. I fixed that by setting:
exec-once = sleep 1; hyprctl dispatch workspace 1 &
. This will make Hyprland always start in Workspace 1, without sacrificing startup speed.
Any news on this?
I would love to get persistent workspaces working in wlr/hyprland
, but don't want to have to make an invisible terminal window for each one!
With a bit of help I'd potentially be able to see if this is something I could add, but I'd need a bit of explaination of how to go about it first.
I managed to modify the code and add persistent workspaces, but it shows the workspace twice if there's a window in it. I can probably fix it if I have time, but I won't be able to continue working on this for a while.
@MonstrousOgre why not share your code so we can help? :D
Sure thing. You can find my changes at my fork MonstrousOgre / Waybar_hyprland_persistent. Just compare my latest commit with the previous one to see my changes.
Also slight correction about my previous comment. Looks like I'm seeing the workspaces twice (on each monitor, totally 4 times) because I have a dual monitor setup.
Just a few things to note before anyone wants to contribute.
- The reading of the JSON config for persistent workspaces is taken care of and works similar to [sway/workspaces]
- The number of
WorkspaceManager
instances for each bar is equal to the number of monitors. In my case, this would be 2 per bar. But since there are two bars (one per monitor again), there are totally 4 instances ofWorkspaceManager
per application. Someone with 3 monitors would have 9 instances per application. - For every persistent workspace in the config, I ended up creating a new workspace in each
WorkspaceManager
. This is probably not the best approach and why it's showing up multiple times. Creating a new workspace manager only for persistent workspaces might be a better solution. - I used
spdlog::info
a few times to see what's happening behind the scenes. It'll need to be replaced withspdlog::debug
when PR is raised.
I'll start working on this again when I can but I've pushed my code if anyone else wants to go ahead.
@MonstrousOgre How do I add persistent workspaces in the waybar config? How many of them?
Like this ?:
"wlr/workspaces": {
"persistent_workspaces": true,
or this ?:
"wlr/workspaces": {
"persistent_workspaces": 10,
I have tried both ways, and they both don't work.
@HanoJing here's the config I was testing with
"persistent_workspaces": {
"1": [],
"4": [],
"5": ["eDP-1", "HDMI-A-1"],
"7": ["eDP-1", "HDMI-A-1"],
"9": ["HDMI-A-1"],
"10": ["eDP-1"]
}
The array for each workspace determines what monitor/output it'll show up on. If it's an empty array, it'll show up on all monitors.
That's how it works for [sway/workspaces] too and I wanted to keep consistency.
@MonstrousOgre Ah, I see.
It sadly still doesn't work. This is my config:
"persistent_workspaces": {
"1": [],
"2": [],
"3": [],
"4": [],
"5": [],
"6": [],
"7": [],
"8": [],
"9": [],
"10": [],
"11": ["DP-3"]
},
@HanoJing Is it inside [wlr/workspaces]? I forgot to mention that. Mine is actually something like this.
"wlr/workspaces": {
"persistent_workspaces": {
"1": [],
"4": [],
"5": ["eDP-1", "HDMI-A-1"],
"7": ["eDP-1", "HDMI-A-1"],
"9": ["HDMI-A-1"],
"10": ["eDP-1"]
}
}
ohh, yup, mine is not inside wlr/workspaces.
Update: Yes! It works! And I even don't have the issue you described with duplicate workspaces on either monitor!
Do you have multiple monitors? The duplicate workspaces issue shouldn't be present if there's only one monitor. If you have multiple, well then... there might be another reason I'm seeing duplicates on mine.
If you have multiple monitors, do you have any workspaces that are "bound" to a monitor? I'm guessing that's another possible reason I'm seeing duplicates.
Do you have multiple monitors? The duplicate workpspaces issue shouldn't be present if there's only one monitor. If you have multiple, well then... there might be another reason I'm seeing duplicates on mine.
Yes. I have a dual-monitor setup.
If you have multiple monitors, do you have any workspaces that are "bound" to a monitor? I'm guessing that's another possible reason I'm seeing duplicates.
Yes. Here's my hyprland.conf: hyprland-conf.log
Then there's probably another reason I'm seeing duplicates. I'll have to make sure not to break it for others if I try to fix it for myself.
The parts of the config where I bind workspaces to monitors are:
monitor=DP-2,2560x1440@60,1920x0,1
workspace=DP-2,1
workspace=DP-2,2
workspace=DP-2,3
workspace=DP-2,4
workspace=DP-2,5
workspace=DP-2,6
workspace=DP-2,7
workspace=DP-2,8
workspace=DP-2,9
workspace=DP-2,10
monitor=DP-3,1920x1080@60,0x0,1
workspace=DP-3,11
and
wsbind=11,DP-3
wsbind=1,DP-2
wsbind=2,DP-2
wsbind=3,DP-2
wsbind=4,DP-2
wsbind=5,DP-2
wsbind=6,DP-2
wsbind=7,DP-2
wsbind=8,DP-2
wsbind=9,DP-2
wsbind=10,DP-2
@MonstrousOgre Do you mind If I take a look at your hyprland.conf
and waybar config
?
This is just a hunch but what's your "all-outputs"
set to in your Waybar config for wlr/workspaces? Is it even there in your config?
This is just a hunch but what's your
"all-outputs"
set to in your Waybar config for wlr/workspaces? Is it even there in your config?
Nope, I haven't got it set.
That might be it. If you don't mind, could you set it to true and see if you get duplicates?
sure
Yes! I get duplicates!