aboutsummaryrefslogtreecommitdiffstats
path: root/deckit
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-16 17:54:32 +0100
committerDanilo M. <danix@danix.xyz>2026-11-16 17:54:32 +0100
commit72f0f05096cea0695a6b65c8c911c43b89b791c0 (patch)
treebd72c5c85429d7d83afab46e627fccc4d1386d21 /deckit
parent903a4527a9ed8802800c0fd0c09123ef3cde4c55 (diff)
downloaddeck-it-72f0f05096cea0695a6b65c8c911c43b89b791c0.tar.gz
deck-it-72f0f05096cea0695a6b65c8c911c43b89b791c0.zip
fix(xbox): follow a power change quickly
Diffstat (limited to 'deckit')
-rw-r--r--deckit/modules/xbox.py8
1 files changed, 7 insertions, 1 deletions
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):