#!/usr/bin/env bash # Cascade move: column → workspace (incl. empty trailing) → monitor (cycles) # usage: niri-move.sh up|down set -euo pipefail dir="${1:?usage: niri-move.sh up|down}" opp=$([ "$dir" = down ] && echo up || echo down) cur=$(niri msg --json focused-window) [ "$cur" = "null" ] && exit 0 out() { niri msg --json focused-output | jq -r '.name // "none"'; } sig() { niri msg --json focused-window | jq -rc '[.workspace_id, (.layout.pos_in_scrolling_layout // null)]'; } # 1) reorder within the column s0=$(sig); niri msg action "move-window-$dir" >/dev/null 2>&1 || true [ "$(sig)" != "$s0" ] && exit 0 # 2) workspace in that direction (including the empty trailing one) s0=$(sig); niri msg action "move-window-to-workspace-$dir" >/dev/null 2>&1 || true [ "$(sig)" != "$s0" ] && exit 0 # 3) adjacent monitor… or wrap to the far-end monitor o0=$(out); niri msg action "move-window-to-monitor-$dir" >/dev/null 2>&1 || true [ "$(out)" != "$o0" ] && exit 0 while :; do prev=$(out) niri msg action "move-window-to-monitor-$opp" >/dev/null 2>&1 || true [ "$(out)" = "$prev" ] && break done