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
-7
View File
@@ -37,10 +37,3 @@ dispatch=$(<"$TEST_LOG")
[[ $dispatch == *'workspace = "2"'* ]] || fail "floating terminal targets active workspace" "$dispatch"
[[ $dispatch == *"xdg-terminal-exec --app-id=org.omarchy.terminal"* ]] || fail "floating terminal dispatch launches Omarchy terminal" "$dispatch"
pass "floating terminal targets active workspace"
: >"$TEST_LOG"
OMARCHY_LAUNCH_WORKSPACE=7 "$ROOT/bin/omarchy-launch-floating-terminal-with-presentation" "echo hello"
dispatch=$(<"$TEST_LOG")
[[ $dispatch == *'workspace = "7"'* ]] || fail "floating terminal honors explicit launch workspace" "$dispatch"
pass "floating terminal honors explicit launch workspace"
+11 -4
View File
@@ -80,11 +80,18 @@ assert(
'launcher delete keeps launcher open after confirmation'
)
assert(
confirmDeleteMatch[1].includes('OMARCHY_LAUNCH_WORKSPACE='),
'launcher delete passes launch workspace to remover'
confirmDeleteMatch[1].includes('Util.hyprExecCommand(command)'),
'launcher delete routes remover through Hyprland'
)
const activateMatch = launcherQml.match(/function activateIndex\(index\) \{([\s\S]*?)\n \}/)
assert(activateMatch, 'launcher activateIndex function exists')
assert(
!activateMatch[1].includes('entry.execute()'),
'launcher does not execute desktop entries directly'
)
assert(
launcherQml.includes('function focusedWorkspaceName()'),
'launcher captures focused workspace'
activateMatch[1].includes('gtk-launch') && activateMatch[1].includes('Util.hyprExecCommand'),
'launcher routes desktop entry launch through Hyprland'
)
JS
+63
View File
@@ -0,0 +1,63 @@
#!/bin/bash
set -euo pipefail
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
run_node_test <<'JS'
const fs = require('fs')
const utilQml = fs.readFileSync(path.join(root, 'shell/Commons/Util.qml'), 'utf8')
assert(
utilQml.includes('import Quickshell'),
'shell launch helper can read Omarchy path'
)
assert(
utilQml.includes('Quickshell.env("OMARCHY_PATH")'),
'shell launch helper uses Omarchy path'
)
assert(
/function hyprExecCommand\(command\)[\s\S]*omarchy-hyprland-launch/.test(utilQml),
'shell launch helper routes through Hyprland launch command'
)
JS
tmp_dir="$(mktemp -d)"
trap 'rm -rf "$tmp_dir"' EXIT
cat >"$tmp_dir/hyprctl" <<'SCRIPT'
#!/bin/bash
case "$1" in
activeworkspace)
printf '{"id":2,"name":"2"}\n'
;;
dispatch)
printf '%s\n' "$2" >>"$TEST_LOG"
;;
esac
SCRIPT
chmod +x "$tmp_dir/hyprctl"
cat >"$tmp_dir/jq" <<'SCRIPT'
#!/bin/bash
cat >/dev/null
printf '2\n'
SCRIPT
chmod +x "$tmp_dir/jq"
export TEST_LOG="$tmp_dir/log"
export PATH="$tmp_dir:$ROOT/bin:$PATH"
export HYPRLAND_INSTANCE_SIGNATURE=test
"$ROOT/bin/omarchy-hyprland-launch" "echo hello"
dispatch=$(<"$TEST_LOG")
[[ $dispatch == *'workspace = "2"'* ]] || fail "hyprland launch targets active workspace" "$dispatch"
[[ $dispatch == *'hl.exec_cmd("echo hello"'* ]] || fail "hyprland launch dispatches command" "$dispatch"
pass "hyprland launch targets active workspace"
unset HYPRLAND_INSTANCE_SIGNATURE
"$ROOT/bin/omarchy-hyprland-launch" "printf fallback > $(printf '%q' "$tmp_dir/fallback")"
[[ $(<"$tmp_dir/fallback") == "fallback" ]] || fail "hyprland launch falls back outside Hyprland"
pass "hyprland launch falls back outside Hyprland"