add(hyprland): workspace-toggle

workspace-toggle force workspace toggle between special and nonspecial;
improve user intuitive action.
This commit is contained in:
kenji
2026-05-07 11:34:56 -05:00
parent f76b350d94
commit 1c1ba8b776
3 changed files with 26 additions and 2 deletions
+1
View File
@@ -14,6 +14,7 @@
./hypr/rules.nix ./hypr/rules.nix
./scripts/movement.nix ./scripts/movement.nix
./scripts/workspace-toggle.nix
]; ];
wayland.windowManager.hyprland.enable = true; wayland.windowManager.hyprland.enable = true;
wayland.windowManager.hyprland.systemd.enable = false; # for UWSM support... wayland.windowManager.hyprland.systemd.enable = false; # for UWSM support...
+2 -2
View File
@@ -68,14 +68,14 @@
"SUPER, E, Toggle Workspace Overview, overview:toggle" "SUPER, E, Toggle Workspace Overview, overview:toggle"
] ]
++ ( ++ (
# Generate binds for Super + [1-5] to switch workspaces on current monitor # Generate binds for Super + [1-5] to switch workspaces with special workspace toggle support
# and Super + Shift + [1-5] to move window to workspace on current monitor # and Super + Shift + [1-5] to move window to workspace on current monitor
builtins.concatLists (builtins.genList ( builtins.concatLists (builtins.genList (
i: let i: let
ws = i + 1; ws = i + 1;
key = toString ws; key = toString ws;
in [ in [
"SUPER, ${key}, Switch to workspace ${toString ws}, split:workspace, ${toString ws}" "SUPER, ${key}, Switch to workspace ${toString ws}, exec, workspace-toggle ${toString ws}"
"SUPER SHIFT, ${key}, Move window to workspace ${toString ws}, split:movetoworkspace, ${toString ws}" "SUPER SHIFT, ${key}, Move window to workspace ${toString ws}, split:movetoworkspace, ${toString ws}"
] ]
) )
@@ -0,0 +1,23 @@
{pkgs, ...}: let
workspace-toggle = pkgs.writeShellScriptBin "workspace-toggle" ''
#!/usr/bin/env bash
target_workspace="$1"
# Get current workspace info
current=$(${pkgs.hyprland}/bin/hyprctl activeworkspace -j | ${pkgs.jq}/bin/jq -r '.id')
# Check if we're in a special workspace (negative ID)
if [[ $current -lt 0 ]]; then
# We're in a special workspace, switch to target workspace using split:workspace
${pkgs.hyprland}/bin/hyprctl dispatch split:workspace "$target_workspace"
elif [[ $current -eq $target_workspace ]]; then
# We're already on the target workspace, toggle back to previous
${pkgs.hyprland}/bin/hyprctl dispatch workspace previous
else
# We're on a different workspace, switch to target using split:workspace
${pkgs.hyprland}/bin/hyprctl dispatch split:workspace "$target_workspace"
fi
'';
in {
home.packages = [workspace-toggle];
}