-
-
Notifications
You must be signed in to change notification settings - Fork 765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[hyprland/workspaces] Implement workspace taskbars #3868
base: master
Are you sure you want to change the base?
Conversation
42a17e1
to
d207ec7
Compare
@Alexays could you take a look at this PR? |
3cd5c21
to
074ff2d
Compare
Add a list of window titles and icons to each workspace (like wlr/taskbar but grouped by workspace). Only implemented on hyprland for now.
Use format from config instead of hardcoding
- orientation - icon-size - icon-theme
This seems to be an old bug that has been made visible with the new workspace taskbars feature. Sometimes, when closing a window and re-opening a window of the same program, hyprland reuses the window address. Since m_orphanWindowMap was not being cleaned up on window close, the new window would not be updated properly.
Fix another older bug where the title of a window will not be updated after moving it to another monitor. In onWindowMoved, when moving an orphan window to the display of the current bar, that window should no longer be an orphan.
Use a vector instead of a map for for storing the workspace windows. This orders the windows by the time they were added to the workspace, instead of sorting by address (which is effectively a random order). The new ordering seems to match the wlr/taskbar module
Windows were not being shown or updated unless the window-rewrite config were present.
- Add missing CSS class to manpage - Fix rare segfault when address is not found (seems to only happen when compiled for production)
@Alexays I've been using this feature daily for 2 months and haven't encountered any issues. |
@Alexays Please |
Thanks for this PR! Is it possible to have such functionality in the improved hyprland/workspaces like this wlr/taskbar config below?
|
@n-connect "hyprland/workspaces": {
"format": "{icon}: {windows}", // Change to your preferred format
"workspace-taskbar": {
"enable": true,
"format": "{icon} {title:.20}", // Change to your preferred format
"icon-size": 16,
"icon-theme": "Numix-Circle",
"on-click-window": "windowClick.sh {address} {button}"
}
} Where windowClick.sh points to a script like this: #!/bin/bash
address=$1
# https://api.gtkd.org/gdk.c.types.GdkEventButton.button.html
button=$2
if [ $button -eq 1 ]; then
# Left click: focus window. The cursor:no_warps lines are optional.
hyprctl keyword cursor:no_warps true
hyprctl dispatch focuswindow address:$address
hyprctl keyword cursor:no_warps false
elif [ $button -eq 2 ]; then
# Middle click: maximize window
# TODO: Use the corresponding hyprctl dispatch command. I don't know what would 'maximize' mean in a tiling window manager like hyprland
elif [ $button -eq 3 ]; then
# Right click: close window
hyprctl dispatch closewindow address:$address
fi |
@n-connect If you want to change the icon that is shown for a specific app, you can do the following:
|
Fair enough. Either possibility of getting the same icons as in war/taskbar, or one with your samples above is perfect.
I just need to git magic the latest numbered release, plus your PR into one local copy to do compile it. I hope I can find find my previous notes about cmus and its https stream PR :) |
This PR is already up to date, you can just Also let me know if you are using arch, then it's much easier to install just by modifying the PKGBUILD. |
Sorry, I don't understand what you mean. Is there a bug? |
Sorry, short version:
bind = ALT, Tab, cyclenext
bind = ALT, Tab, bringactivetotop
These two above are related to the shellscript you've sent earlier.
This one is a completely generic one. I'll crosscheck with 0.12.0 packaged version if it happens again. |
Ah I see. You seem to have a typo on your script: I don't know why the windows are being hidden, this change should not affect it at all. Let me know if it also happens with the 0.12.0 base. |
Good catch, thx! For a "fresh" client/window it works now. I'll fix in the previos one, if someone get here from Google/etc search have a working script... I'm still in the same XDG session where the clients got hidden. One of them with many tabs, a kitty in "hidden phase". That Thx again. |
Glad to help :) |
Made another build with latest release version + this PR merged: git clone --branch 0.12.0 https://github.com/Alexays/Waybar.git
cd Waybar;git pull origin pull/3868/head As a result got Final, fully working windowClick.sh: #!/bin/bash
address=$1
# https://api.gtkd.org/gdk.c.types.GdkEventButton.button.html
button=$2
if [ $button -eq 1 ]; then
# Left click: focus window.
# The cursor:no_warps are optional. Set to not catch and move the cursor into the middle of screen as a result of "focuswindow"
hyprctl keyword cursor:no_warps true
hyprctl dispatch focuswindow address:$address
hyprctl dispatch bringactivetotop
hyprctl keyword cursor:no_warps false
elif [ $button -eq 2 ]; then
# Middle click: maximize window
hyprctl dispatch fullscreenstate 1
elif [ $button -eq 3 ]; then
# Right click: close window
hyprctl dispatch closewindow address:$address
fi |
Because of missing lib/dev packages the following modules has not been compiled in: [2025-03-10 10:58:16.726] [warning] module privacy: Unknown module: privacy
[2025-03-10 10:58:16.726] [warning] module mpris: Unknown module: mpris
[2025-03-10 10:58:16.731] [warning] Waybar has been built without rfkill support. @Alexays , The following additional packages are necessary to install to build waybar, at least on Debian. Would you accept a README.md update with the below packages? (edit) apt install libfftw3-dev libiniparser-dev libupower-glib-dev libpipewire-0.3-dev libplayerctl-dev libjack-dev libwireplumber-0.5-dev libsndio-dev libgtk-layer-shell-dev libasound2-dev portaudio19-dev libsdl2-dev With the above only epoll-shim and libinotify are missing during "Original" / debian package based waybar with mpris/audio/privacy:
|
Thanks for all the info setting up workspace taskbars.
Edit:
Thx |
Unfortunately, I don't think it's possible to get the keyboard state from a GDK mouse-click event. Feel free to correct me if I'm wrong, though. Similarly, getting the keyboard state inside the script is hard, especially without root access. I found this answer, but I wasn't able to make it work in wayland. However, you could easily do something like a double-click or triple-click to bring back the window: #!/bin/bash
address=$1
# https://api.gtkd.org/gdk.c.types.GdkEventButton.button.html
button=$2
# Globals for double-click detection
LAST_CLICK_FILE="/tmp/waybar_taskbar_last_click"
DOUBLE_CLICK_THRESHOLD=0.3 # seconds
is_double_click() {
current_time=$(date +%s.%N)
if [ -f "$LAST_CLICK_FILE" ]; then
last_time=$(cat "$LAST_CLICK_FILE")
time_diff=$(awk "BEGIN {print $current_time - $last_time}")
if [ "$(echo "$time_diff < $DOUBLE_CLICK_THRESHOLD" | bc -l)" -eq 1 ]; then
# Double-click detected
rm -f "$LAST_CLICK_FILE"
return 0
fi
fi
echo "$current_time" > "$LAST_CLICK_FILE"
return 1 # Not a double-click.
}
on_double_click() {
# Put your double-click action here. For example:
hyprctl dispatch moveactive exact 0 0
}
if [ "$button" -eq 1 ]; then
if is_double_click; then
on_double_click
exit 0
fi
# Left click: focus window.
# The cursor:no_warps are optional. Set to not catch and move the cursor into the middle of screen as a result of "focuswindow"
hyprctl keyword cursor:no_warps true
hyprctl dispatch focuswindow address:$address
hyprctl dispatch bringactivetotop
hyprctl keyword cursor:no_warps false
elif [ "$button" -eq 2 ]; then
# Middle click: maximize window.
hyprctl dispatch fullscreenstate 1
elif [ "$button" -eq 3 ]; then
# Right click: close window.
hyprctl dispatch closewindow address:$address
fi |
Thx for the answer and the details. Based on your answer I recon there's no keyboard-press detection code in waybar at all. Thinking about it, it makes sense, maybe I'm the first one tries to solve an issue coming from a different part of hyprland, via a 4th type of click. (The root cause why I've had the whole modkey + mouse-click idea is, that the Edit: checked the stackoverflow link, I'm not sure if its the only direction, eg. you need root level access for this. I've checked all "hypr" processes - All of them running in my user's name. Still the various binds works well. About mouse I'm using 'autowaybar' which polls mouse position to determine if waybar should be unhidden or not. So I'm guessing none of them needs root access - there's should be a different solution, I'll just need to check Hyprland's code around 'bind'. Anyway the real problem is still with monitor disable/enable. Thx again. |
Summary
This PR expands the functionality of
hyprland/workspaces
to make it behave more like thewlr/taskbar
module. See #2656 for a high-level description.A full fix of #2656 would require porting those changes to the
sway/workspaces
module as well. I don't use Sway and I'm not familiar on how it works, but if anyone is interested in giving it a go in a separate PR feel free to ping me and I'll do my best to help.Config changes
Adds the following changes to the
hyprland/workspaces
config:Notice how
workspace-taskbar.enable
defaults tofalse
, so existing configs shouldn't be affected by these changes without opting in.What's missing
I'm mainly waiting for your feedback on the config json names and structure. Once that's done I will update the wiki with the finalized spec.
Screenshots
Default CSS, old config file (defaults to old, text-based icons)
Default CSS, new config file (default format is just the icon)
Default CSS, windows with first 10 chars of title and bigger icon
Tooltip shows full window title.
Allows an arbitrary format
My setup with custom CSS
Same CSS as above, vertical orientation
Action when clicking window
You can use the
on-click-window
config to set the command that will be executed when a specific window is clicked.{address}
will be replaced with the address of the clicked window.{button}
will be replaced with the pressed button number. See GdkEventButton.button.For example:
I personally require a more complex logic, so I use
on-click-window
to call an external script.