Update multi-display workspace handling

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-02-16 17:15:28 +00:00
parent 7fa058293b
commit a467f953bb
4 changed files with 78 additions and 49 deletions

View File

@@ -1,24 +1,24 @@
BASE_WS="$1"
SELECTED_WORKSPACE_BASE="$1"
ACTION="$2"
current_ws_id="$(hyprctl -j activeworkspace | jq -r '.id')"
ws_json="$(hyprctl -j workspaces)"
max_ws_id="$(echo "$ws_json" | jq -r '[.[] | .id] | max')"
BLOCK_SIZE=10
total_blocks=$(((max_ws_id - 1) / BLOCK_SIZE + 1))
current_block=$(((current_ws_id - 1) / BLOCK_SIZE))
target_ws=$((current_block * BLOCK_SIZE + BASE_WS))
current_workspace_id="$(hyprctl -j activeworkspace | jq -r '.id')"
workspace_json="$(hyprctl -j workspaces)"
if [ "$target_ws" -eq "$current_ws_id" ]; then
next_block=$(( (current_block + 1) % total_blocks ))
target_ws=$(( next_block * BLOCK_SIZE + BASE_WS ))
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_ws"
hyprctl dispatch movetoworkspacesilent "$target_workspace_id"
else
hyprctl dispatch workspace "$target_ws"
hyprctl dispatch workspace "$target_workspace_id"
fi