Waybar
Waybar copied to clipboard
Hyprland/workspaces improvements and further development
I'm creating this issue so we can keep track of further development for the newly implemented hyprland/workspaces module (by @Anakael in https://github.com/Alexays/Waybar/pull/2264)
Here are some features I would personally like to see:
- [x] Urgent class
- [x] Focused class
- [x] Visible class (In PR: https://github.com/Alexays/Waybar/pull/2408)
- [x] Option to only show active workspaces (same as above)
- [x] Persistent workspaces (+persistent css class)
- [x] Multi-monitor: option to disable showing all workspaces on every output
- [x] on-click action
- [x] on-scroll action
- [ ] Improve special workspace integration (add support for https://github.com/hyprwm/Hyprland/pull/3163)
- [x] Refactor persistent workspaces to use Hyprland's new persistent workspace rule (https://github.com/Alexays/Waybar/pull/2603)
Bugs to fix:
- [x] #2495
- [ ] #2484
- [ ] #2555
Active (focused) class is already implemented.
Wiki is updated: https://github.com/Alexays/Waybar/wiki/Module:-Hyprland (Also fixed wrong class name in https://github.com/Alexays/Waybar/wiki/Module:-Workspaces)
Hi, It seems the icons for the workspaces specified in the configuration only work if they’re specified for a workspace ID, not its name. The icons also aren’t updated when a workspace is created, but the icons appear fine if the bar is killed and recreated. Oh and the active workspace doesn’t seem to be tracked properly.
- For me, multi-monitor displaying does not work. All the workspaces are shown on both bars in my dual monitor setup.
- Names also do not work, with Waybar claiming that the argument
{name}
does not exist. - As in above user's case, the active workspace does not track properly in a dual monitor setup. If I switch or hover mouse over a workspace on the other monitor, it will still show the workspace from the other monitor as being active. Active workspace only updates when an unseen workspace is switched to.
I can open up a separate issue for this, if it sounds interesting.
@maxwelljens @VincentBerthier Can you guys share your configs?
For me, the multi-monitor displaying & active workspace tracking does work properly. I use this config:
"hyprland/workspaces": {
"format": "{name}",
"format-icons": {
"active": "",
"default": "",
"persistent": ""
},
"on-scroll-up": "hyprctl dispatch workspace r-1",
"on-scroll-down": "hyprctl dispatch workspace r+1",
"all-outputs": false,
"persistent_workspaces": {
"*": 5
}
}
and my style.css:
button {
box-shadow: inset 0 -3px transparent;
border: none;
border-radius: 0;
}
button:hover {
transition-duration: .1s;
background: inherit;
box-shadow: inset 0 -3px #ffffff;
}
#workspaces button {
padding: 0 5px;
background-color: #ffffff;
color: #2e3440;
}
#workspaces button.persistent {
background-color: #d8dee9;
color: #4c566a;
}
#workspaces button.active {
box-shadow: inset 0 -4px #4c566a;
background-color: #ffffff;
}
@maxwelljens Some questions for you:
Active workspace only updates when an unseen workspace is switched to.
What do you mean by "unseen workspace"?
Names also do not work, with Waybar claiming that the argument {name} does not exist.
Can you share the exact error?
That’s not me for the unseen ^^ I changed my configuration to use IDs instead of names, it works fine now. I think.
@zjeffer I tried many different configurations and the one you presented is one of those I tried. None of the options seem to do anything, except format
.
"hyprland/workspaces": {
"format": "{id}",
"all-outputs": false,
"persistent_workspaces": {
"*": 5
}
},
The error in question is this, if you set "format": "{name}"
:
[2023-08-11 08:54:32.006] [error] hyprland/workspaces: argument not found
[2023-08-11 08:54:32.121] [error] hyprland/workspaces: argument not found
It is definitely that element, because if I set "format": "{id}"
or "format": "{}"
then it does not show that error. No other errors are present either.
What do you mean by "unseen workspace"?
I should have said "not visible" instead. If we have three workspaces 1, 2, and 3:
- 1 is visible on left monitor
- 2 is visible on right monitor
- 3 is not visible, whether assigned to left or right monitor
- If I switch between 1 and 2 in Hyprland, then the active workspace in Waybar is always shown as being either 1 or 2, regardless of which workspace is actually active in Hyprland.
- If I switch to 3 in Hyprland, then the active workspace will correctly switch to 3 in Waybar, as expected.
Hope that was clear enough.
That's so strange, I don't have any of those issues.
Here's a video of me moving my mouse between two of my monitors:
https://github.com/Alexays/Waybar/assets/4633209/36a3b3a4-8dbd-4988-bd9b-7c3bae78e13c
It was kind of difficult to record so I only managed to record the workspace regions of my left and middle monitors. I move the mouse and the active workspace changes. Active means a white line appears at the bottom. Non-empty workspaces are a slightly whiter color. At the end of the video, I moved to my third monitor, which makes the other monitors not have an active workspace.
This seems to work perfectly fine on my system. Can you double-check you are running the latest version?
According to waybar --version
, I am indeed running the latest version 0.9.20.
Is that the release version or the latest git commit? Because the 0.9.20 release was published a month ago, while my PR with the changes necessary for persistent workspaces was merged two weeks ago (https://github.com/Alexays/Waybar/commit/600653538b778cf9528bb7a230428418b5b9220b)
I use v0.9.20-64-gb084bf72
from the AUR, which is the latest git version.
I believe it is the release version. I use Waybar as distributed in the Fedora 38 repositories.
Alright, so you'll have to compile Waybar yourself or wait until the next version releases.
@VincentBerthier Can you check your version as well?
0.9.20 too, so… Hmm… Well, I guess this explains that.
I don't know if this is how the module is intended to work but it is not working as expected for me.
It arbitrarily numbers persistent workspaces from left to right not respecting which workspace I've bound to each monitor via hyprland configs.
I don't know if it is feasible but we should be able to pick which individual workspace to show as persistent or automatically show all workspaces bound to the monitor instead of specifying the amount of persistent workspaces
Edit: grammar
I don't know if this is how the module is intended to work
I use it together with my fork of Duckonaut's split-monitor-workspaces plugin. This plugin automatically binds workspaces to monitors, and sets up keybinds so that you can for example do this:
- Automatically bind 5 workspaces to each monitor, based on the formula:
-
workspace_id = monitor_id * nr_of_workspaces_per_monitor + 1
- So, the first workspace on the second monitor (= monitor ID 1) will have
workspace_id
=1*5+1
=6
-
- Assign keybinds like
Super+4
, to go to the 4th workspace on the currently focused monitor.
The good thing about this approach is that I can use the exact same formula in Waybar, so that the binds the plugin makes correspond to the same workspaces that are shown on each monitor's bar. The plugin assigns workspace 6 to the second monitor, and Waybar also assigns workspace 6 to that monitor. Keybinds work perfectly and without configuration.
If I connect a monitor it has never seen before, it will automatically create 5 persistent workspaces in Waybar and the plugin. All without ever touching Hyprland's config file: no need to set binds. I just tell Waybar and the plugin settings to both add 5 workspaces per monitor, and that's it.
The problem with this approach is exactly as you describe: if you manually set your own binds in your hyprland config, the IDs you set in your Hyprland config won't necessarily match Waybar's formula.
The solution to this is manually setting the persistent_workspaces just like you would in wlr/workspaces (https://github.com/Alexays/Waybar/wiki/Module:-Workspaces#persistent-workspaces). The good news: I also implemented this in hyprland/workspaces :)
Instead of using "*": 5
, you can manually set which monitors should show which workspaces:
"persistent_workspaces": {
"1": ["DP-1"], // workspace ID : [array of monitors to show this workspace on, ...]
"2": ["DP-1"],
"3": ["DP-1"]
// and so on, up to 5...
"6": ["DP-2"],
// up to 10...
"11": ["DP-3"],
// up to 15
}
I dislike this approach which is why I implemented the "*": 5
automatic approach, but I understand if you want to do it manually like above, to have more control over the workspace names.
Let me know if this works for you @proudhon
Thank you so much for the explanation, I couldn't find the manual setup in the wiki and therefore I ended up being confused.
I will try both the approaches and I will give you a feedback asap.
Manual setup works flawlessly, thank you so much. I will try your own approach asap as it looks more flexible (especially because my docking station tends to mess with my monitor names very often).
I just switched from sway to hyprland using the hyprland/workspaces module. Working great so far but one thing is odd to me. Clicking on a active worksapce does not bring me back to the last active workspace even tough I have
binds {
allow_workspace_cycles = true
workspace_back_and_forth = true
}
in my hyprland config. Is that something that is yet to be implemented or did I screw up my config somewhere in the process of switching?
@mischw That is not yet implemented, I'll see if I can implement that today.
@mischw I just looked at the Hyprland wiki and the description of those settings implied it should work with the current implementation, so I tested it on my system and it already seems to work fine.
Are you using the latest release?
@zjeffer Oh sorry, I didn't see that there was just a new release. I will try that. Can't get it to compile right now but will try again tomorrow.
Fantastic work, thank you very much for implementing!
Is there a way to style workspaces that are currently visible on a monitor differently than those that are not shown on any monitor?
Is there a way to style workspaces that are currently visible on a monitor differently than those that are not shown on any monitor?
@jr64 Not yet, I'm thinking of implementing that soon, though
Just curious if we need to go down this road or request something more similar to the approach we're taking in nixpkgs in discussion https://github.com/NixOS/nixpkgs/pull/251115 about just enabling the experimental flag and using wlr/workspaces as-is. It looks like it functions fine so I'm not sure whether its worth investing effort into this module anymore. @zjeffer opinions/context?
Looks like urgent got merged if you want to update the checklist.
@khaneliman Some things that come to mind why I dislike that approach:
- The persistent workspaces implementation is quite limited in wlr/workspaces.
- With wlr/workspaces, you have to specify
"<workspace>": [<array of monitors to show workspace on>]
. This is quite cumbersome and doesn't automatically work with keybinds. With my changes in hyprland/workspaces, you can simply specify"*": 5
to show 5 workspaces on each monitor. - Persistent workspaces are named automatically based on hyprland monitor IDs, to make sure the names match between waybar and plugins like split-monitor-workspaces.
- This would need to be ported to wlr/workspaces but it uses hyprland specific stuff (monitor IDs) to accomplish the automatic workspace naming. I actually tried to implement this before hyprland/workspaces existed, see here: https://github.com/Alexays/Waybar/pull/2251.
- See this issue for more info about why I implemented it this way.
@khaneliman Some things that come to mind why I dislike that approach:
* The persistent workspaces implementation is quite limited in wlr/workspaces. * With wlr/workspaces, you have to specify `"<workspace>": [<array of monitors to show workspace on>]`. This is quite cumbersome and doesn't automatically work with keybinds. With my changes in hyprland/workspaces, you can simply specify `"*": 5` to show 5 workspaces on each monitor. * Persistent workspaces are named automatically based on hyprland monitor IDs, to make sure the names match between waybar and plugins like [split-monitor-workspaces](https://github.com/zjeffer/split-monitor-workspaces). * This would need to be ported to wlr/workspaces but it uses hyprland specific stuff (monitor IDs) to accomplish the automatic workspace naming. I actually tried to implement this before hyprland/workspaces existed, see here: [[wlr/workspaces] Improve persistent_workspaces by allowing fixed nr of workspaces per monitor #2251](https://github.com/Alexays/Waybar/pull/2251). * See [this issue](https://github.com/Alexays/Waybar/issues/2243) for more info about why I implemented it this way.
The interesting thing is that the wlr implementation supports my use case better of wanting to show specific workspaces on a monitor, albeit in poor experience of declaring it in configuration. I use specific icons/names per monitor and can't seem to get that functioning with hyprland persistent workspaces.
wlr/workspaces
hyprland/workspaces
The video workspace is assigned to a different monitor but the perisistent workspace implementation in hyprland shows it on my other monitor. Ignore the ugly green css, i was testing that PR for persistent vs empty. lol
The interesting thing is that the wlr implementation supports my use case better of wanting to show specific workspaces on a monitor, albeit in poor experience of declaring it in configuration. I use specific icons/names per monitor and can't seem to get that functioning with hyprland persistent workspaces.
Your wlr persistent workspace configuration should be able to work the same on both modules, unless I made a mistake while programming it ;)
The video workspace is assigned to a different monitor but the perisistent workspace implementation in hyprland shows it on my other monitor.
That sounds more like a bug than an intended feature. Can you create a separate issue for this, with a minimal reproducible example?
Your wlr persistent workspace configuration should be able to work the same on both modules, unless I made a mistake while programming it ;)
My understanding from the wiki was that I had to just specify a number of workspaces for a monitor and then it just loops through and assigns that many.
hyprland/workspaces
{
"hyprland/workspaces": {
"all-outputs": false,
"active-only": "false",
"format": "{icon}",
"format-icons": {
"1": "",
"2": "",
"3": "",
"4": "",
"5": "",
"6": "",
"7": "",
"8": "",
"urgent": "",
"default": "",
"persistent": "persistent",
"empty": "empty"
},
"persistent_workspaces": {
"*": 8,
"DP-3": 1
}
},
wlr/workspaces
"wlr/workspaces": {
"all-outputs": false,
"active-only": "false",
"on-click": "activate",
"format": "{icon}",
"format-icons": {
"1": "",
"2": "",
"3": "",
"4": "",
"5": "",
"6": "",
"7": "",
"8": "",
"urgent": "",
"default": ""
},
"persistent_workspaces": {
"1": [
"DP-3"
],
"2": [
"DP-1"
],
"3": [
"DP-1"
],
"4": [
"DP-1"
],
"5": [
"DP-1"
],
"6": [
"DP-1"
],
"7": [
"DP-1"
],
"8": [
"DP-1"
]
}
}
If i can just put an array of workspaces into that instead of a single number, that'd be nicer. I tried to but it doesn't seem to work.
hyprland/workspaces ideal but probably hard to support
"hyprland/workspaces": {
"all-outputs": false,
"active-only": "false",
"format": "{icon}",
"format-icons": {
"1": "",
"2": "",
"3": "",
"4": "",
"5": "",
"6": "",
"7": "",
"8": "",
"urgent": "",
"default": "",
"persistent": "persistent",
"empty": "empty"
},
"persistent_workspaces": {
"*": [
2,
3,
4,
5,
6,
7,
8
],
"DP-3": 1
}
},
The interesting thing is that the wlr implementation supports my use case better of wanting to show specific workspaces on a monitor, albeit in poor experience of declaring it in configuration. I use specific icons/names per monitor and can't seem to get that functioning with hyprland persistent workspaces.
Your wlr persistent workspace configuration should be able to work the same on both modules, unless I made a mistake while programming it ;)
See, I didn't see that referenced in the wiki so I did try just copying that config style over and it did work, as intended. :P That works for me, actually... and solves the issue I had with empty persistent workspaces crashing waybar when i clicked on them in wlr/workspaces.
Yeah the wiki should be updated with that info and more examples but I've been kind of busy with other stuff lately and didn't feel like it :)