From 8a65ebb9a3a5529f083c099e666b1591daefec0c Mon Sep 17 00:00:00 2001 From: Grant Wiley Date: Wed, 12 Aug 2026 17:53:14 -0400 Subject: [PATCH] Wait for ttfx before closing its terminal --- bin/omarchy-system-lock | 2 ++ test/shell.d/system-lock-test.sh | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/bin/omarchy-system-lock b/bin/omarchy-system-lock index 3c9ea6b5d8c9..53e4ca5a0efb 100755 --- a/bin/omarchy-system-lock +++ b/bin/omarchy-system-lock @@ -21,4 +21,6 @@ fi # Avoid running screensaver when locked pkill -x ttfx 2>/dev/null || true +# ttfx handles SIGTERM asynchronously, so keep its terminal alive until it exits. +timeout 1s pidwait -x ttfx 2>/dev/null || true pkill -f '[o]rg.omarchy.screensaver' 2>/dev/null || true diff --git a/test/shell.d/system-lock-test.sh b/test/shell.d/system-lock-test.sh index 05eb98110290..da79eac045e0 100755 --- a/test/shell.d/system-lock-test.sh +++ b/test/shell.d/system-lock-test.sh @@ -11,7 +11,7 @@ mock_bin="$tmpdir/bin" call_log="$tmpdir/calls" mkdir -p "$mock_bin" -for command in omarchy-shell hyprctl pkill; do +for command in omarchy-shell hyprctl pkill timeout; do cat >"$mock_bin/$command" <<'SH' #!/bin/bash printf '%s %s\n' "$(basename "$0")" "$*" >>"$CALL_LOG" @@ -25,10 +25,12 @@ SH chmod +x "$mock_bin"/* PATH="$mock_bin:$PATH" CALL_LOG="$call_log" "$ROOT/bin/omarchy-system-lock" -mapfile -t kills < <(rg '^pkill ' "$call_log") - -[[ ${kills[0]} == "pkill -x ttfx" ]] || - fail "system lock stops ttfx before closing its terminal" "calls: ${kills[*]}" -[[ ${kills[1]} == "pkill -f [o]rg.omarchy.screensaver" ]] || - fail "system lock closes the screensaver terminal after ttfx" "calls: ${kills[*]}" -pass "system lock stops ttfx before closing its terminal" +mapfile -t shutdown < <(rg '^(pkill|timeout) ' "$call_log") + +[[ ${shutdown[0]} == "pkill -x ttfx" ]] || + fail "system lock stops ttfx before closing its terminal" "calls: ${shutdown[*]}" +[[ ${shutdown[1]} == "timeout 1s pidwait -x ttfx" ]] || + fail "system lock waits for ttfx to exit" "calls: ${shutdown[*]}" +[[ ${shutdown[2]} == "pkill -f [o]rg.omarchy.screensaver" ]] || + fail "system lock closes the screensaver terminal after ttfx exits" "calls: ${shutdown[*]}" +pass "system lock waits for ttfx before closing its terminal"