diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-21 20:13:23 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-21 20:13:23 +0200 |
| commit | 696f3ad4f65a6516549544af13a9646f57ae523e (patch) | |
| tree | 10004eac68626f413da40c2287dd1838fbb82f86 /desktop/modules/status/test-statusctl.sh | |
| parent | 34a6a3cd65370fd31877da0c54abcae15d69d3a4 (diff) | |
| download | quickshell-696f3ad4f65a6516549544af13a9646f57ae523e.tar.gz quickshell-696f3ad4f65a6516549544af13a9646f57ae523e.zip | |
feat(status): report a running game as its own presentation state
status.gaming is written by the shell's game detector and presentation is
the OR of it and the manual file, but statusctl read only the manual half.
A game therefore asserted the presentation effects while the waybar pill
still read deactivated.
Report gaming as a third state, for presentation only. The watch follows
status.gaming as well as its own file, and emits only on a real change so
an unchanged rewrite draws nothing.
Toggle is refused while a game holds the mode: the detector reasserts the
file within its poll, so the write would not stick. set stays allowed, the
manual half is worth setting for when the game exits.
gaming stays out of MODES. The detector owns that file and nothing here
may write it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'desktop/modules/status/test-statusctl.sh')
| -rwxr-xr-x | desktop/modules/status/test-statusctl.sh | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/desktop/modules/status/test-statusctl.sh b/desktop/modules/status/test-statusctl.sh index 7b1b188..38da27c 100755 --- a/desktop/modules/status/test-statusctl.sh +++ b/desktop/modules/status/test-statusctl.sh @@ -92,5 +92,46 @@ kill "$watcher2" 2>/dev/null wait "$watcher2" 2>/dev/null check "watch reports deactivated when absent" "1" "$(grep -c '"class": *"deactivated"' "$out2")" +# A running game is reported as its own state, not as plain activated: the +# widget draws a different icon and the tooltip says why the mode is on. +rm -f "$tmp/status.presentation" +printf '1\n' > "$tmp/status.gaming" +out3="$tmp/watch3.out" +"$ctl" presentation watch > "$out3" 2>/dev/null & +watcher3=$! +sleep 0.5 +kill "$watcher3" 2>/dev/null +wait "$watcher3" 2>/dev/null +check "watch reports gaming" "1" "$(grep -c '"class": *"gaming"' "$out3")" + +# The gaming file is the shell's, so presentation's own file stays off and +# `get` keeps reporting the manual half rather than the OR. +check "get reads the manual half" "0" "$("$ctl" presentation get)" + +# Toggling while a game runs is refused: the detector would reassert it, so a +# write here would not stick. +"$ctl" presentation toggle 2>/dev/null +check "toggle refused while gaming" "1" "$?" +check "toggle wrote nothing" "0" "$("$ctl" presentation get)" + +# The refusal is specific to presentation; another mode toggles normally with +# a game running. +"$ctl" dnd set 0 +"$ctl" dnd toggle +check "dnd toggles while gaming" "1" "$("$ctl" dnd get)" + +# A game ending redraws the widget, which is why the watch follows +# status.gaming as well as its own file. +out4="$tmp/watch4.out" +"$ctl" presentation watch > "$out4" 2>/dev/null & +watcher4=$! +sleep 0.3 +printf '0\n' > "$tmp/status.gaming.tmp" +mv -f "$tmp/status.gaming.tmp" "$tmp/status.gaming" +sleep 0.5 +kill "$watcher4" 2>/dev/null +wait "$watcher4" 2>/dev/null +check "game ending redraws" "1" "$(grep -c '"class": *"deactivated"' "$out4")" + printf '\n%d passed, %d failed\n' "$pass" "$fail" [[ "$fail" -eq 0 ]] |
