# shellcheck shell=bash MOVE=false while getopts "m" opt; do case $opt in m) MOVE=true ;; *) exit 1 ;; esac done shift $((OPTIND - 1)) SELECTED_WORKSPACE_BASE="$1" 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 [ "$MOVE" = true ]; then hyprctl dispatch movetoworkspacesilent "$target_workspace_id" else hyprctl dispatch workspace "$target_workspace_id" fi