Silence jq noise when the reload guard probes dead Hyprland instances
hyprctl prints "Couldn't connect ..." on stdout for stale instance dirs left in /run/user/*/hypr/, so jq's parse error leaked into pacman's pre-transaction hook output. The dead instances were already skipped correctly; only the stderr noise escaped. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ls3ump7hcv4oNnjWW5AXmn
This commit is contained in:
co-authored by
Claude Fable 5
parent
9ca5f63f86
commit
abe5b1ff9f
@@ -31,7 +31,9 @@ option_bool() {
|
|||||||
local signature="$2"
|
local signature="$2"
|
||||||
local option="$3"
|
local option="$3"
|
||||||
|
|
||||||
hyprctl_instance "$runtime_dir" "$signature" -j getoption "$option" 2>/dev/null | jq -r '.bool'
|
# A dead instance makes hyprctl print "Couldn't connect ..." on stdout, so
|
||||||
|
# silence jq too and let the failed pipeline skip the instance.
|
||||||
|
hyprctl_instance "$runtime_dir" "$signature" -j getoption "$option" 2>/dev/null | jq -r '.bool' 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
instances() {
|
instances() {
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ fake_hyprctl="$test_tmp/hyprctl"
|
|||||||
signature="test-signature"
|
signature="test-signature"
|
||||||
runtime_dir="$run_root/1000"
|
runtime_dir="$run_root/1000"
|
||||||
|
|
||||||
mkdir -p "$runtime_dir/hypr/$signature"
|
dead_signature="dead-signature"
|
||||||
|
|
||||||
|
mkdir -p "$runtime_dir/hypr/$signature" "$runtime_dir/hypr/$dead_signature"
|
||||||
|
|
||||||
cat >"$fake_hyprctl" <<'BASH'
|
cat >"$fake_hyprctl" <<'BASH'
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
@@ -22,6 +24,10 @@ cat >"$fake_hyprctl" <<'BASH'
|
|||||||
printf '%s\t%s\n' "$XDG_RUNTIME_DIR" "$*" >>"$FAKE_HYPRCTL_LOG"
|
printf '%s\t%s\n' "$XDG_RUNTIME_DIR" "$*" >>"$FAKE_HYPRCTL_LOG"
|
||||||
|
|
||||||
case "$*" in
|
case "$*" in
|
||||||
|
*'--instance dead-signature '*)
|
||||||
|
printf "Couldn't connect to %s/hypr/dead-signature/.socket.sock. (4)\n" "$XDG_RUNTIME_DIR"
|
||||||
|
exit 4
|
||||||
|
;;
|
||||||
*'getoption misc.disable_autoreload'*)
|
*'getoption misc.disable_autoreload'*)
|
||||||
printf '{"option":"misc.disable_autoreload","bool":%s,"set":true}\n' "${FAKE_DISABLE_AUTORELOAD:-false}"
|
printf '{"option":"misc.disable_autoreload","bool":%s,"set":true}\n' "${FAKE_DISABLE_AUTORELOAD:-false}"
|
||||||
;;
|
;;
|
||||||
@@ -39,7 +45,7 @@ FAKE_HYPRCTL_LOG="$hyprctl_log" \
|
|||||||
HYPRCTL="$fake_hyprctl" \
|
HYPRCTL="$fake_hyprctl" \
|
||||||
OMARCHY_HYPRLAND_RELOAD_GUARD_RUN_ROOT="$run_root" \
|
OMARCHY_HYPRLAND_RELOAD_GUARD_RUN_ROOT="$run_root" \
|
||||||
OMARCHY_HYPRLAND_RELOAD_GUARD_STATE_DIR="$state_dir" \
|
OMARCHY_HYPRLAND_RELOAD_GUARD_STATE_DIR="$state_dir" \
|
||||||
"$ROOT/bin/omarchy-hyprland-reload-guard" pause
|
"$ROOT/bin/omarchy-hyprland-reload-guard" pause 2>"$test_tmp/pause-stderr"
|
||||||
|
|
||||||
state_file="$state_dir/$signature"
|
state_file="$state_dir/$signature"
|
||||||
[[ -f $state_file ]] || fail "reload guard stores Hyprland state on pause"
|
[[ -f $state_file ]] || fail "reload guard stores Hyprland state on pause"
|
||||||
@@ -48,6 +54,10 @@ grep -Fx "$expected_state" "$state_file" >/dev/null || fail "reload guard record
|
|||||||
grep -F 'hl.config({ misc = { disable_autoreload = true }, debug = { suppress_errors = true } })' "$hyprctl_log" >/dev/null || fail "reload guard pauses autoreload with hyprctl eval"
|
grep -F 'hl.config({ misc = { disable_autoreload = true }, debug = { suppress_errors = true } })' "$hyprctl_log" >/dev/null || fail "reload guard pauses autoreload with hyprctl eval"
|
||||||
pass "reload guard pauses live Hyprland reloads"
|
pass "reload guard pauses live Hyprland reloads"
|
||||||
|
|
||||||
|
[[ ! -e $state_dir/$dead_signature ]] || fail "reload guard skips instances hyprctl cannot reach"
|
||||||
|
[[ ! -s $test_tmp/pause-stderr ]] || fail "reload guard pauses dead Hyprland instances quietly" "$(cat "$test_tmp/pause-stderr")"
|
||||||
|
pass "reload guard skips dead Hyprland instances quietly"
|
||||||
|
|
||||||
: >"$hyprctl_log"
|
: >"$hyprctl_log"
|
||||||
FAKE_HYPRCTL_LOG="$hyprctl_log" \
|
FAKE_HYPRCTL_LOG="$hyprctl_log" \
|
||||||
HYPRCTL="$fake_hyprctl" \
|
HYPRCTL="$fake_hyprctl" \
|
||||||
|
|||||||
Reference in New Issue
Block a user