feat(tools): add Umbriel window launcher toggle script

This commit is contained in:
Prad Nukala committed 2026-10-16 14:23:31 -04:00
1 parent f587c06d05
commit c586bfbf95
1 file changed
+25
+25
View File
@@ -0,0 +1,25 @@
#!/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
# the first when focus is elsewhere.
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
else (map(.focused) | index(true)) as $i
| 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 "$@"