From abe5b1ff9f65f99a053e04a3db3f81d50f6cd000 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 1 Aug 2026 22:12:01 -0500 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_01Ls3ump7hcv4oNnjWW5AXmn --- bin/omarchy-hyprland-reload-guard | 4 +++- test/shell.d/hyprland-reload-guard-test.sh | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/bin/omarchy-hyprland-reload-guard b/bin/omarchy-hyprland-reload-guard index 218da79e..c0b5868c 100755 --- a/bin/omarchy-hyprland-reload-guard +++ b/bin/omarchy-hyprland-reload-guard @@ -31,7 +31,9 @@ option_bool() { local signature="$2" 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() { diff --git a/test/shell.d/hyprland-reload-guard-test.sh b/test/shell.d/hyprland-reload-guard-test.sh index 6d8ccb12..05ab23ee 100755 --- a/test/shell.d/hyprland-reload-guard-test.sh +++ b/test/shell.d/hyprland-reload-guard-test.sh @@ -14,7 +14,9 @@ fake_hyprctl="$test_tmp/hyprctl" signature="test-signature" 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' #!/bin/bash @@ -22,6 +24,10 @@ cat >"$fake_hyprctl" <<'BASH' printf '%s\t%s\n' "$XDG_RUNTIME_DIR" "$*" >>"$FAKE_HYPRCTL_LOG" 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'*) 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" \ OMARCHY_HYPRLAND_RELOAD_GUARD_RUN_ROOT="$run_root" \ 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" [[ -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" 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" FAKE_HYPRCTL_LOG="$hyprctl_log" \ HYPRCTL="$fake_hyprctl" \