2026-10-16 14:23:31 -04:00
|
|
|
#!/bin/sh
|
|
|
|
|
# umbriel-launch PATTERN COMMAND...
|
|
|
|
|
# Focus the next workspace window whose app id matches PATTERN (a
|
|
|
|
|
# case-insensitive jq regex), cycling through matches on repeated presses;
|
|
|
|
|
# with none open, spawn COMMAND. Scratchpad windows are skipped: they have
|
|
|
|
|
# their own toggles. Umbriel counterpart of niri-launch / omarchy-cycle.
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
|
|
[ $# -ge 2 ] || { echo "usage: umbriel-launch PATTERN COMMAND..." >&2; exit 2; }
|
|
|
|
|
pattern=$1
|
|
|
|
|
shift
|
|
|
|
|
|
|
|
|
|
# Matches in a stable order (window id); the one after the focused match, or
|
2026-10-18 13:29:52 -04:00
|
|
|
# the first when focus is elsewhere. `.active` is the one window with keyboard
|
|
|
|
|
# focus; `.focused` is set on every output's last-focused window.
|
2026-10-16 14:23:31 -04:00
|
|
|
target=$(umbriel windows --json | jq -r --arg p "$pattern" '
|
|
|
|
|
[.[] | select(.scratchpad == "" and (.app_id | test($p; "i")))] | sort_by(.id)
|
|
|
|
|
| if length == 0 then empty
|
2026-10-18 13:29:52 -04:00
|
|
|
else (map(.active) | index(true)) as $i
|
2026-10-16 14:23:31 -04:00
|
|
|
| if $i == null then .[0].id else .[($i + 1) % length].id end
|
|
|
|
|
end')
|
|
|
|
|
|
|
|
|
|
if [ -n "$target" ]; then
|
|
|
|
|
exec umbriel msg "window-focus:$target"
|
|
|
|
|
fi
|
|
|
|
|
exec umbriel msg spawn "$@"
|