Hyprland
Hyprland copied to clipboard
Option to autoclose an special workspace when I switch to a different workspace
Description
I use a special workspace for my email and a special one for music. This works great, because I can toggle them at any time and return to the last active workspace just by toggling again.
But sometimes I don't want to return, but to switch to a different workspace. Currently this requires me to do two things (order not important):
- toggle special workspace
- switch to new workspace
Is there an easy way to bundle this into a single bind
?
Is this something which can be an option to the workspace
dispatcher (e.g. if passing parameter true, special workspaces will be closed)?
..., exec, hyprctl --batch ...
I tried hyprctl --batch 'dispatch togglespecialworkspace; dispatch workspace 3'
as an example, but it does not work properly.
- I need to specify the special workspace to toggle and I have at least two
- when invoked on a normal workspace, it opens the special workspace and then tries to switch to workspace 3
Maybe I miss something here?
Still I wonder if a function closespecialworkspace
is doable. It would allow me to:
bind = , F1, closespecialworkspace
bind = , F1, workspace, 1
or with an extra (optional?) parameter for workspace:
bind = , F1, workspace, 1, true
add hyprctl monitors -j | jq .[0][\"specialWorkspace\"][\"name\"]
to get the togglespecalworkspace
arg
add extra logic for more custom behaviour, this is easily scriptable
It is scriptable, I came up with this:
~/.config/hypr/scripts/switch-workspace-closing-special.sh:
SPECIAL=`hyprctl monitors -j | jq .[0][\"specialWorkspace\"][\"name\"]`
SPECIAL=${SPECIAL//\"/}
[ $SPECIAL ] && hyprctl dispatch togglespecialworkspace ${SPECIAL:8}
hyprctl dispatch workspace $1
and I bind it like this:
bind = , F1, exec, ~/.config/hypr/scripts/switch-workspace-closing-special.sh 1
bind = , F2, exec, ~/.config/hypr/scripts/switch-workspace-closing-special.sh 2
bind = , F3, exec, ~/.config/hypr/scripts/switch-workspace-closing-special.sh 3
bind = , F4, exec, ~/.config/hypr/scripts/switch-workspace-closing-special.sh 4
Still I don't like it very much since it could be implemented in hyprland (developer time given...) and needs to invoke 4 commands.
Still I don't like it very much since it could be implemented in hyprland (developer time given...) and needs to invoke 4 commands.
Also it makes it more complicated to integrate with workspace buttons in things like waybar. There I cannot use the script mentioned above (or I am not seeing how to....).