Remove redundant Hyprland launch wrapper
With initial workspace tracking disabled, windows naturally open on the active workspace. Remove the explicit Hyprland workspace dispatch and let shell actions, shell restarts, and presentation terminals launch directly.
This commit is contained in:
@@ -1,30 +0,0 @@
|
|||||||
#!/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)"
|
|
||||||
# hyprctl dispatch exits 0 even on Lua errors, so check for "ok" output.
|
|
||||||
if [[ -n $workspace && $(hyprctl dispatch "function() hl.exec_cmd($(lua_quote "$cmd"), { workspace = $(lua_quote "$workspace") }) end" 2>/dev/null) == ok ]]; then
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
exec bash -lc "$cmd"
|
|
||||||
@@ -6,13 +6,4 @@
|
|||||||
cmd="$*"
|
cmd="$*"
|
||||||
presentation_script="omarchy-show-logo; $cmd; if (( \$? != 130 )); then omarchy-show-done; fi"
|
presentation_script="omarchy-show-logo; $cmd; if (( \$? != 130 )); then omarchy-show-done; fi"
|
||||||
|
|
||||||
shell_quote() {
|
exec setsid uwsm-app -- xdg-terminal-exec --app-id=org.omarchy.terminal --title=Omarchy -e bash -c "$presentation_script"
|
||||||
local value=$1
|
|
||||||
|
|
||||||
printf "'"
|
|
||||||
printf "%s" "$value" | sed "s/'/'\\\\''/g"
|
|
||||||
printf "'"
|
|
||||||
}
|
|
||||||
|
|
||||||
terminal_command="setsid uwsm-app -- xdg-terminal-exec --app-id=org.omarchy.terminal --title=Omarchy -e bash -c $(shell_quote "$presentation_script")"
|
|
||||||
exec omarchy-hyprland-launch "$terminal_command"
|
|
||||||
|
|||||||
@@ -28,8 +28,7 @@ if (( attempt == 50 )); then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -v launch_command 'setsid quickshell -n -p %q >/dev/null 2>&1 &' "$CONFIG_DIR"
|
setsid quickshell -n -p "$CONFIG_DIR" >/dev/null 2>&1 &
|
||||||
omarchy-hyprland-launch "$launch_command"
|
|
||||||
|
|
||||||
for (( attempt = 0; attempt < 20; attempt++ )); do
|
for (( attempt = 0; attempt < 20; attempt++ )); do
|
||||||
OMARCHY_SHELL_IPC_TIMEOUT=0.5s omarchy-shell shell ping >/dev/null 2>&1 && exit 0
|
OMARCHY_SHELL_IPC_TIMEOUT=0.5s omarchy-shell shell ping >/dev/null 2>&1 && exit 0
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import QtQuick
|
|||||||
QtObject {
|
QtObject {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
readonly property string omarchyPath: Quickshell.env("OMARCHY_PATH")
|
|
||||||
|
|
||||||
function clamp(value, min, max) {
|
function clamp(value, min, max) {
|
||||||
var n = Number(value)
|
var n = Number(value)
|
||||||
if (!isFinite(n)) return min
|
if (!isFinite(n)) return min
|
||||||
@@ -41,8 +39,8 @@ QtObject {
|
|||||||
return "'" + String(value || "").replace(/'/g, "'\\''") + "'"
|
return "'" + String(value || "").replace(/'/g, "'\\''") + "'"
|
||||||
}
|
}
|
||||||
|
|
||||||
function hyprExecCommand(command) {
|
function execDetached(command) {
|
||||||
return [omarchyPath + "/bin/omarchy-hyprland-launch", command]
|
Quickshell.execDetached(["bash", "-lc", command])
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPlainObject(value) {
|
function isPlainObject(value) {
|
||||||
|
|||||||
@@ -488,8 +488,7 @@ Item {
|
|||||||
function run(command) {
|
function run(command) {
|
||||||
if (!command) return
|
if (!command) return
|
||||||
|
|
||||||
launcher.command = Util.hyprExecCommand(command)
|
Util.execDetached(command)
|
||||||
launcher.startDetached()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleTransparency() {
|
function toggleTransparency() {
|
||||||
@@ -786,8 +785,6 @@ Item {
|
|||||||
clearTooltip()
|
clearTooltip()
|
||||||
}
|
}
|
||||||
|
|
||||||
Process { id: launcher }
|
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: tooltipTimer
|
id: tooltipTimer
|
||||||
interval: 400
|
interval: 400
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ Item {
|
|||||||
|
|
||||||
root.beginLaunchFeedback(entry)
|
root.beginLaunchFeedback(entry)
|
||||||
root.dismiss()
|
root.dismiss()
|
||||||
Quickshell.execDetached(Util.hyprExecCommand("gtk-launch " + Util.shellQuote(desktopId)))
|
Util.execDetached("gtk-launch " + Util.shellQuote(desktopId))
|
||||||
}
|
}
|
||||||
|
|
||||||
function requestDeleteIndex(index) {
|
function requestDeleteIndex(index) {
|
||||||
@@ -297,7 +297,7 @@ Item {
|
|||||||
var name = root.entryName(entry)
|
var name = root.entryName(entry)
|
||||||
var command = Util.shellQuote(root.omarchyPath + "/bin/omarchy-remove-launcher-entry") + " " + Util.shellQuote(desktopId) + " " + Util.shellQuote(name)
|
var command = Util.shellQuote(root.omarchyPath + "/bin/omarchy-remove-launcher-entry") + " " + Util.shellQuote(desktopId) + " " + Util.shellQuote(name)
|
||||||
root.dismiss()
|
root.dismiss()
|
||||||
Quickshell.execDetached(Util.hyprExecCommand(command))
|
Util.execDetached(command)
|
||||||
}
|
}
|
||||||
|
|
||||||
function beginLaunchFeedback(entry) {
|
function beginLaunchFeedback(entry) {
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ Item {
|
|||||||
var command = String(action || "")
|
var command = String(action || "")
|
||||||
if (!command) return
|
if (!command) return
|
||||||
|
|
||||||
Quickshell.execDetached(Util.hyprExecCommand(command))
|
Util.execDetached(command)
|
||||||
}
|
}
|
||||||
|
|
||||||
function rowHeightForDetail(detail) {
|
function rowHeightForDetail(detail) {
|
||||||
|
|||||||
@@ -7,33 +7,17 @@ source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
|
|||||||
tmp_dir="$(mktemp -d)"
|
tmp_dir="$(mktemp -d)"
|
||||||
trap 'rm -rf "$tmp_dir"' EXIT
|
trap 'rm -rf "$tmp_dir"' EXIT
|
||||||
|
|
||||||
cat >"$tmp_dir/hyprctl" <<'SCRIPT'
|
cat >"$tmp_dir/setsid" <<'SCRIPT'
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
case "$1" in
|
printf '%s\n' "$*" >"$TEST_LOG"
|
||||||
activeworkspace)
|
|
||||||
printf '{"id":2,"name":"2"}\n'
|
|
||||||
;;
|
|
||||||
dispatch)
|
|
||||||
printf '%s\n' "$2" >>"$TEST_LOG"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
SCRIPT
|
SCRIPT
|
||||||
chmod +x "$tmp_dir/hyprctl"
|
chmod +x "$tmp_dir/setsid"
|
||||||
|
|
||||||
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 TEST_LOG="$tmp_dir/log"
|
||||||
export PATH="$tmp_dir:$ROOT/bin:$PATH"
|
export PATH="$tmp_dir:$ROOT/bin:$PATH"
|
||||||
export HYPRLAND_INSTANCE_SIGNATURE=test
|
|
||||||
|
|
||||||
"$ROOT/bin/omarchy-launch-floating-terminal-with-presentation" "echo hello"
|
"$ROOT/bin/omarchy-launch-floating-terminal-with-presentation" "echo hello"
|
||||||
|
|
||||||
dispatch=$(<"$TEST_LOG")
|
launch=$(<"$TEST_LOG")
|
||||||
[[ $dispatch == *'workspace = "2"'* ]] || fail "floating terminal targets active workspace" "$dispatch"
|
[[ $launch == *"xdg-terminal-exec --app-id=org.omarchy.terminal"* ]] || fail "floating terminal launches Omarchy terminal" "$launch"
|
||||||
[[ $dispatch == *"xdg-terminal-exec --app-id=org.omarchy.terminal"* ]] || fail "floating terminal dispatch launches Omarchy terminal" "$dispatch"
|
pass "floating terminal launches Omarchy terminal"
|
||||||
pass "floating terminal targets active workspace"
|
|
||||||
|
|||||||
@@ -100,8 +100,8 @@ assert(
|
|||||||
'launcher delete closes launcher after confirmation'
|
'launcher delete closes launcher after confirmation'
|
||||||
)
|
)
|
||||||
assert(
|
assert(
|
||||||
confirmDeleteMatch[1].includes('Util.hyprExecCommand(command)'),
|
confirmDeleteMatch[1].includes('Util.execDetached(command)'),
|
||||||
'launcher delete routes remover through Hyprland'
|
'launcher delete runs remover through the shell'
|
||||||
)
|
)
|
||||||
|
|
||||||
const activateMatch = launcherQml.match(/function activateIndex\(index\) \{([\s\S]*?)\n \}/)
|
const activateMatch = launcherQml.match(/function activateIndex\(index\) \{([\s\S]*?)\n \}/)
|
||||||
@@ -111,8 +111,8 @@ assert(
|
|||||||
'launcher does not execute desktop entries directly'
|
'launcher does not execute desktop entries directly'
|
||||||
)
|
)
|
||||||
assert(
|
assert(
|
||||||
activateMatch[1].includes('gtk-launch') && activateMatch[1].includes('Util.hyprExecCommand'),
|
activateMatch[1].includes('gtk-launch') && activateMatch[1].includes('Util.execDetached'),
|
||||||
'launcher routes desktop entry launch through Hyprland'
|
'launcher runs desktop entry launch through the shell'
|
||||||
)
|
)
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
|
|||||||
@@ -42,12 +42,6 @@ touch "$restart_root/shell/shell.qml"
|
|||||||
ln -s "$ROOT/bin/omarchy-shell" "$restart_bin/omarchy-shell"
|
ln -s "$ROOT/bin/omarchy-shell" "$restart_bin/omarchy-shell"
|
||||||
ln -s "$ROOT/bin/omarchy-cmd-missing" "$restart_bin/omarchy-cmd-missing"
|
ln -s "$ROOT/bin/omarchy-cmd-missing" "$restart_bin/omarchy-cmd-missing"
|
||||||
|
|
||||||
cat >"$restart_bin/omarchy-hyprland-launch" <<'SH'
|
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
bash -c "$1"
|
|
||||||
SH
|
|
||||||
|
|
||||||
cat >"$restart_bin/qs" <<'SH'
|
cat >"$restart_bin/qs" <<'SH'
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
@@ -91,7 +85,7 @@ if [[ ${1:-} == "-j" && ${2:-} == "monitors" ]]; then
|
|||||||
fi
|
fi
|
||||||
SH
|
SH
|
||||||
|
|
||||||
chmod +x "$restart_bin/qs" "$restart_bin/quickshell" "$restart_bin/hyprctl" "$restart_bin/omarchy-hyprland-launch"
|
chmod +x "$restart_bin/qs" "$restart_bin/quickshell" "$restart_bin/hyprctl"
|
||||||
|
|
||||||
printf '101\n202\n' >"$restart_state"
|
printf '101\n202\n' >"$restart_state"
|
||||||
|
|
||||||
|
|||||||
@@ -9,55 +9,8 @@ const fs = require('fs')
|
|||||||
const utilQml = fs.readFileSync(path.join(root, 'shell/Commons/Util.qml'), 'utf8')
|
const utilQml = fs.readFileSync(path.join(root, 'shell/Commons/Util.qml'), 'utf8')
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
utilQml.includes('import Quickshell'),
|
/function execDetached\(command\)[\s\S]*Quickshell\.execDetached\(\["bash", "-lc", command\]\)/.test(utilQml),
|
||||||
'shell launch helper can read Omarchy path'
|
'detached command helper uses a login shell'
|
||||||
)
|
|
||||||
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
|
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"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user