aboutsummaryrefslogtreecommitdiffstats
path: root/deckit/server.py
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-13 14:06:41 +0100
committerDanilo M. <danix@danix.xyz>2026-11-13 14:06:41 +0100
commit863f7453f9e136cadc93db9f3f0b8f257f798ce8 (patch)
treea24c2453dd0d9b8e7317378ee8da56e205a0f3bb /deckit/server.py
parentfe55526cbc6015c4268ee155f21bcb11de5609b5 (diff)
downloaddeck-it-863f7453f9e136cadc93db9f3f0b8f257f798ce8.tar.gz
deck-it-863f7453f9e136cadc93db9f3f0b8f257f798ce8.zip
feat(tablet): a font of the PC's for the dim cover's clock
[tablet] clock_font names a font family installed on the PC; the server finds its file with fc-match and serves it at /fonts/clock, and the cover's clock uses it, the date too while clock_font_date is on (default). fc-match falls back to any font, so the route answers only when the returned family is the one named; otherwise the page font stays. The font file never enters the repo, so a personal-use font can be used on one's own tablet without redistributing it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'deckit/server.py')
-rw-r--r--deckit/server.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/deckit/server.py b/deckit/server.py
index 875a19d..2ced8dd 100644
--- a/deckit/server.py
+++ b/deckit/server.py
@@ -142,6 +142,19 @@ def nerd_font():
return _font["p"]
+def clock_font():
+ """[tablet] clock_font's file, for the dim cover's clock; None when unset
+ or not installed (fc-match falls back to any font, so the family must match)."""
+ family = CFG.get("tablet", {}).get("clock_font", "")
+ if not family:
+ return None
+ out = _run(["fc-match", "-f", "%{family}\n%{file}", family])
+ names, _, file = out.partition("\n")
+ if family.lower() not in (n.strip().lower() for n in names.split(",")) or not Path(file).is_file():
+ return None
+ return Path(file)
+
+
def load_token() -> str:
"""A per-machine secret the tablet's browser holds as a cookie."""
path = token_path()
@@ -206,6 +219,9 @@ class Handler(BaseHTTPRequestHandler):
if path == "/fonts/nerd.ttf":
f = nerd_font()
return self._send(200, f.read_bytes(), "font/ttf", cache=True) if f else self._send(404)
+ if path == "/fonts/clock":
+ f = clock_font()
+ return self._send(200, f.read_bytes(), mimetypes.guess_type(f)[0] or "font/ttf") if f else self._send(404)
if path.startswith("/api/"):
if not self._authed():
return self._send(401)