From 72f0f05096cea0695a6b65c8c911c43b89b791c0 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Mon, 16 Nov 2026 17:54:32 +0100 Subject: fix(xbox): follow a power change quickly --- deckit/modules/xbox.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'deckit/modules') diff --git a/deckit/modules/xbox.py b/deckit/modules/xbox.py index bd2fd6e..60f402e 100644 --- a/deckit/modules/xbox.py +++ b/deckit/modules/xbox.py @@ -72,6 +72,7 @@ COMMANDS = { FAST = 30 # seconds between presence and console reads SLOW = 600 # seconds between profile, games, achievements and friends reads +QUICK, QUICK_FOR = 3, 30 # after a command: read every 3s for 30s, until the power state follows # ponytail: renewed by age, not by the XSTS NotAfter (about 16h); a 401 renews early too. XSTS_FOR = 8 * 3600 TITLES = 12 # recent games shown @@ -245,6 +246,7 @@ class Xbox: self.status_lock = threading.Lock() self.slow_at, self.slow_title = None, None self.wake, self.stopping = threading.Event(), False + self.quick_until = 0.0 # read every QUICK seconds until then # --- the refresh token file ---------------------------------------- def _load(self): @@ -512,16 +514,20 @@ class Xbox: raise ModuleError("The console is not reachable from Xbox Live: turn it on by hand once, then retry.") if status.get("errorCode", "OK") != "OK": raise ModuleError(status.get("errorMessage") or status["errorCode"]) + self.quick_until = time.monotonic() + QUICK_FOR self.wake.set() # --- the reader thread ---------------------------------------------- + def next_read(self) -> float: + return QUICK if time.monotonic() < self.quick_until else FAST + def run(self): while not self.stopping: try: self.tick() except Exception as e: self.offline, self.reason = True, str(e) - self.wake.wait(FAST) + self.wake.wait(self.next_read()) self.wake.clear() def start(self): -- cgit v1.2.3