aboutsummaryrefslogtreecommitdiffstats
path: root/deckit/server.py
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-12 09:01:06 +0100
committerDanilo M. <danix@danix.xyz>2026-11-12 09:01:06 +0100
commit512a2b4a2821a1edadf5530d060e3ae5468d75e8 (patch)
treef81dcb1d2238403bdcf68cf9298cc34b6a010672 /deckit/server.py
parentfea2e9b221a2d18f9c73e5763adf662128cea5ec (diff)
downloaddeck-it-512a2b4a2821a1edadf5530d060e3ae5468d75e8.tar.gz
deck-it-512a2b4a2821a1edadf5530d060e3ae5468d75e8.zip
fix(tablet): restore the backlight after a restart or shutdown
The server never ran the modules' stop: `deck-it stop` ends it with SIGTERM and nothing called stop_all, so a shutdown left the tablet dim. A SIGTERM handler now runs stop_all before exiting. The settings from before a dim lived only in memory, so a new server's undim had nothing to put back. They are now kept in ~/.cache/deck-it/dim, and a freshly loaded page asks for undim, since it is never dimmed itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'deckit/server.py')
-rw-r--r--deckit/server.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/deckit/server.py b/deckit/server.py
index f222ecb..875a19d 100644
--- a/deckit/server.py
+++ b/deckit/server.py
@@ -27,6 +27,7 @@ import mimetypes
import os
import re
import secrets
+import signal
import socketserver
import subprocess
import threading
@@ -300,6 +301,9 @@ def serve():
TOKEN = load_token()
REGISTRY = build(CFG)
REGISTRY.start_all()
+ # `deck-it stop` ends the server with SIGTERM; let the modules clean up
+ # (the tablet's backlight) before it goes.
+ signal.signal(signal.SIGTERM, lambda *_: (REGISTRY.stop_all(), os._exit(0)))
threading.Thread(target=sleep.watch, daemon=True).start()
RUNDIR.mkdir(mode=0o700, parents=True, exist_ok=True)
RUNDIR.chmod(0o700)