diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-17 14:39:06 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-17 14:39:06 +0200 |
| commit | e81c248c6243719f62b426dd68b0a74dc5b912d8 (patch) | |
| tree | b72f25252d054e14b9e1c450018c389859e1779b | |
| parent | d7a8b0e7eeac3575b05d1ae5bea4473177de30a1 (diff) | |
| download | quickshell-e81c248c6243719f62b426dd68b0a74dc5b912d8.tar.gz quickshell-e81c248c6243719f62b426dd68b0a74dc5b912d8.zip | |
fix(status): read a missing state file as off, not down
statusctl watch reported class "down" for a missing state file and waybar's presentation rule drew a warning for it. That fires on every fresh session, before anything has written a file, which is the normal off state the registry's own invariant describes. The state was meant to flag a dead registry, but a crashed shell leaves a stale present file, not a missing one, so it never caught that case. get already read a missing file as 0; watch now matches it and the down state is gone.
| -rw-r--r-- | desktop/modules/status/README.md | 2 | ||||
| -rwxr-xr-x | desktop/modules/status/statusctl | 6 | ||||
| -rwxr-xr-x | desktop/modules/status/test-statusctl.sh | 6 |
3 files changed, 9 insertions, 5 deletions
diff --git a/desktop/modules/status/README.md b/desktop/modules/status/README.md index 84736d5..2092890 100644 --- a/desktop/modules/status/README.md +++ b/desktop/modules/status/README.md @@ -56,4 +56,4 @@ before the screen could lock. Points `XDG_RUNTIME_DIR` at a temporary directory, so it never touches live modes. Covers the file format, the atomic write, the toggle, the unknown-mode -error, both the activated report and the absent-file down report. +error, both the activated report and the absent-file off report. diff --git a/desktop/modules/status/statusctl b/desktop/modules/status/statusctl index 6fbb689..8877ff3 100755 --- a/desktop/modules/status/statusctl +++ b/desktop/modules/status/statusctl @@ -82,12 +82,14 @@ tooltip() { case "$1" in activated) printf '%s: on' "$mode" ;; deactivated) printf '%s: off' "$mode" ;; - down) printf '%s: no state file' "$mode" ;; esac } +# A missing file is the off state, not a distinct condition: read_mode already +# reads it as 0, and this is the same path `get` uses. There is no "down": a +# file cannot report whether a watcher is alive, and a missing one is exactly +# what a fresh session looks like. state_now() { - [[ -e "$file" ]] || { printf 'down'; return; } [[ "$(read_mode)" == "1" ]] && printf 'activated' || printf 'deactivated' } diff --git a/desktop/modules/status/test-statusctl.sh b/desktop/modules/status/test-statusctl.sh index 3b8f7ba..82e2de1 100755 --- a/desktop/modules/status/test-statusctl.sh +++ b/desktop/modules/status/test-statusctl.sh @@ -73,7 +73,9 @@ kill "$watcher" 2>/dev/null wait "$watcher" 2>/dev/null check "watch reports activated" "1" "$(grep -c '"class": *"activated"' "$out")" -# A missing file is reported as down, distinct from a mode that is off. +# A missing file is the off state, so the absent-file watch reports off rather +# than a distinct warning: a fresh session has no file until something writes +# one, and that is the normal state. rm -f "$tmp/status.presentation" out2="$tmp/watch2.out" "$ctl" presentation watch > "$out2" 2>/dev/null & @@ -81,7 +83,7 @@ watcher2=$! sleep 0.5 kill "$watcher2" 2>/dev/null wait "$watcher2" 2>/dev/null -check "watch reports down when absent" "1" "$(grep -c '"class": *"down"' "$out2")" +check "watch reports deactivated when absent" "1" "$(grep -c '"class": *"deactivated"' "$out2")" printf '\n%d passed, %d failed\n' "$pass" "$fail" [[ "$fail" -eq 0 ]] |
