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
@@ -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];
}