Launch shell commands on active workspace

This commit is contained in:
David Heinemeier Hansson
2026-06-29 11:26:23 -05:00
parent 4ab3377950
commit 987588f512
7 changed files with 114 additions and 58 deletions
+29
View File
@@ -0,0 +1,29 @@
#!/bin/bash
# omarchy:summary=Launch a command on the active Hyprland workspace
# omarchy:args=<command>
cmd="$*"
[[ -n $cmd ]] || exit 0
lua_quote() {
local value=$1
value=${value//\\/\\\\}
value=${value//\"/\\\"}
value=${value//$'\n'/\\n}
printf '"%s"' "$value"
}
active_workspace() {
hyprctl activeworkspace -j 2>/dev/null | jq -r '.name // .id // empty' 2>/dev/null
}
if [[ -n ${HYPRLAND_INSTANCE_SIGNATURE:-} ]] && omarchy-cmd-present hyprctl && omarchy-cmd-present jq; then
workspace="$(active_workspace)"
if [[ -n $workspace ]] && hyprctl dispatch "function() hl.exec_cmd($(lua_quote "$cmd"), { workspace = $(lua_quote "$workspace") }) end" >/dev/null 2>&1; then
exit 0
fi
fi
exec bash -lc "$cmd"