aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-16 17:20:29 +0100
committerDanilo M. <danix@danix.xyz>2026-11-16 17:20:29 +0100
commiteb81546609a1decc8e8ac4bc3856b6b17269777d (patch)
tree7e5091b8103554d4da72a49e9ff7dbb5e2a90878
parent6d60c2a0af28afd8bde3fc41c92f759e10845221 (diff)
downloadquickshell-eb81546609a1decc8e8ac4bc3856b6b17269777d.tar.gz
quickshell-eb81546609a1decc8e8ac4bc3856b6b17269777d.zip
fix(status): statusctl watch counts status.xbox as gamingHEADmaster
The shell ORs status.xbox into presentation, so the CLI reads it too: the watch emits the gaming class and toggle is refused while the Xbox runs a game, as for a PC game. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
-rw-r--r--desktop/modules/status/README.md11
-rwxr-xr-xdesktop/modules/status/statusctl25
-rwxr-xr-xdesktop/modules/status/test-statusctl.sh17
3 files changed, 39 insertions, 14 deletions
diff --git a/desktop/modules/status/README.md b/desktop/modules/status/README.md
index 1edec03..15bb122 100644
--- a/desktop/modules/status/README.md
+++ b/desktop/modules/status/README.md
@@ -1,8 +1,10 @@
# status
Desktop modes as state: `dnd`, `presentation`, `nolock`, `quiet` and `nolamp`, owned by
-the `Status` singleton and stored as files under `$XDG_RUNTIME_DIR`. A sixth,
-`status.gaming` is written only by the shell's game detector and `status.xbox` only by deck-it while the Xbox runs a game; neither is a mode `statusctl` exposes, and either one turns presentation on.
+the `Status` singleton and stored as files under `$XDG_RUNTIME_DIR`. Two more,
+`status.gaming`, written only by the shell's game detector, and `status.xbox`,
+written only by deck-it while the Xbox runs a game, are not modes `statusctl`
+exposes; either one turns presentation on.
## The files are the interface
@@ -117,8 +119,9 @@ without touching the manual half, so a bar widget would otherwise read
class with its own icon, and `toggle` is refused while it holds: the detector
reasserts the file within its poll, so the write would not stick. `set` is
still allowed, since the manual half is worth setting for when the game exits.
-The watch therefore follows `status.gaming` as well as its own file, and emits
-only on a real change so an unchanged rewrite draws nothing.
+The watch therefore follows `status.gaming` and `status.xbox` as well as its
+own file, and emits only on a real change so an unchanged rewrite draws
+nothing. `status.xbox` counts as gaming in all of this.
## The checks
diff --git a/desktop/modules/status/statusctl b/desktop/modules/status/statusctl
index 7bbae3e..69dc5a1 100755
--- a/desktop/modules/status/statusctl
+++ b/desktop/modules/status/statusctl
@@ -83,17 +83,22 @@ tooltip() {
case "$1" in
activated) printf '%s: on' "$mode" ;;
deactivated) printf '%s: off' "$mode" ;;
- gaming) printf '%s: on (auto: game or call)' "$mode" ;;
+ gaming) printf '%s: on (auto: game, call or Xbox)' "$mode" ;;
esac
}
-# The shell's game detector owns status.gaming and presentation is the OR of
-# the two, so the CLI has to read it to agree with the shell. It is not a mode
-# in MODES: nothing here may write it, and only presentation is affected.
+# The shell's game detector owns status.gaming, deck-it owns status.xbox (a
+# game on the Xbox), and presentation is the OR of them and its own file, so
+# the CLI has to read both to agree with the shell. Neither is a mode in
+# MODES: nothing here may write them, and only presentation is affected.
gaming_on() {
- local v=""
- [[ -e "$DIR/status.gaming" ]] && v="$(tr -d '[:space:]' < "$DIR/status.gaming" 2>/dev/null)"
- [[ "$v" == "1" ]]
+ local f v
+ for f in status.gaming status.xbox; do
+ v=""
+ [[ -e "$DIR/$f" ]] && v="$(tr -d '[:space:]' < "$DIR/$f" 2>/dev/null)"
+ [[ "$v" == "1" ]] && return 0
+ done
+ return 1
}
# A missing file is the off state, not a distinct condition: read_mode already
@@ -158,14 +163,14 @@ case "$action" in
exec 3< <(inotifywait -q -m -e create,close_write,moved_to,delete --format '%f' "$DIR" 2>/dev/null)
watcher=$!
trap 'kill "$watcher" 2>/dev/null' EXIT TERM INT
- # Presentation also follows status.gaming, so a game starting or
- # ending redraws the widget. Emitting only on a real change keeps a
+ # Presentation also follows status.gaming and status.xbox, so a game
+ # starting or ending redraws the widget. Emitting only on a real change keeps a
# write of an unchanged value from firing a duplicate line.
last="$(state_now)"
while read -r changed <&3; do
case "$changed" in
"status.$mode") ;;
- status.gaming) [[ "$mode" == "presentation" ]] || continue ;;
+ status.gaming|status.xbox) [[ "$mode" == "presentation" ]] || continue ;;
*) continue ;;
esac
now="$(state_now)"
diff --git a/desktop/modules/status/test-statusctl.sh b/desktop/modules/status/test-statusctl.sh
index 8042fd1..0c51968 100755
--- a/desktop/modules/status/test-statusctl.sh
+++ b/desktop/modules/status/test-statusctl.sh
@@ -149,6 +149,23 @@ kill "$watcher5" 2>/dev/null
wait "$watcher5" 2>/dev/null
check "first write, created by link, redraws" "1" "$(grep -c '"class": *"gaming"' "$out5")"
+# deck-it writes status.xbox while the Xbox runs a game; it holds
+# presentation on the same way, so the watch follows it too.
+rm -f "$tmp/status.gaming" "$tmp/status.presentation"
+out6="$tmp/watch6.out"
+"$ctl" presentation watch > "$out6" 2>/dev/null &
+watcher6=$!
+sleep 0.3
+printf '1\n' > "$tmp/status.xbox.tmp"
+mv -f "$tmp/status.xbox.tmp" "$tmp/status.xbox"
+sleep 0.5
+kill "$watcher6" 2>/dev/null
+wait "$watcher6" 2>/dev/null
+check "xbox game redraws as gaming" "1" "$(grep -c '"class": *"gaming"' "$out6")"
+"$ctl" presentation toggle 2>/dev/null
+check "toggle refused while the xbox plays" "1" "$?"
+rm -f "$tmp/status.xbox"
+
# quiet is a plain mode like dnd.
"$ctl" quiet set 1
check "quiet set 1" "1" "$("$ctl" quiet get)"