Files
nix/hosts/common/configs/user/gui/hyprland/scripts/bind.sh
2025-02-16 17:15:28 +00:00

25 lines
805 B
Bash

SELECTED_WORKSPACE_BASE="$1"
ACTION="$2"
BLOCK_SIZE=10
current_workspace_id="$(hyprctl -j activeworkspace | jq -r '.id')"
workspace_json="$(hyprctl -j workspaces)"
max_active_workspace_id="$(echo "$workspace_json" | jq -r '[.[] | .id] | max')"
total_blocks=$(((max_active_workspace_id - 1) / BLOCK_SIZE + 1))
current_block=$(((current_workspace_id - 1) / BLOCK_SIZE))
target_workspace_id=$((current_block * BLOCK_SIZE + SELECTED_WORKSPACE_BASE))
if [ "$target_workspace_id" -eq "$current_workspace_id" ]; then
next_block=$(((current_block + 1) % total_blocks))
target_workspace_id=$((next_block * BLOCK_SIZE + SELECTED_WORKSPACE_BASE))
fi
if [ "$ACTION" = "move" ]; then
hyprctl dispatch movetoworkspacesilent "$target_workspace_id"
else
hyprctl dispatch workspace "$target_workspace_id"
fi