diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-10 10:02:44 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-10 10:02:44 +0100 |
| commit | 5ebfb5850713c038e37baddbadde3320aca2c4e4 (patch) | |
| tree | a2842edacb1e7f93f34d2492c6cab9f8cd51dbe7 /deckit/theme.py | |
| parent | 2c7cef2024c201fa9c7c406954121de337071689 (diff) | |
| download | deck-it-5ebfb5850713c038e37baddbadde3320aca2c4e4.tar.gz deck-it-5ebfb5850713c038e37baddbadde3320aca2c4e4.zip | |
fix: follow UDT's font size and live theme changes
UDT gives font sizes to keystone's fonts page, which writes
~/.config/keystone/fonts.json. deck-it hardcoded px sizes, so changing
the size on the fonts page did nothing on the tablet. theme.css now
carries --udt-font-size (override.deckit, else base, 8 to 40px, as
quickshell checks) on html, and deck.css sizes text in rem, scaled from
the old 14px design.
The page loaded theme.css once, so a scheme, wallpaper or size change
reached the tablet only after a reload. The shell now re-reads it every
5s and on visibility, swapping it into a <style> only when it changed,
and sets meta theme-color from --udt-base instead of Macchiato's
hardcoded base.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'deckit/theme.py')
| -rw-r--r-- | deckit/theme.py | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/deckit/theme.py b/deckit/theme.py index 2ed3d51..142a79f 100644 --- a/deckit/theme.py +++ b/deckit/theme.py @@ -21,6 +21,7 @@ wallpaper accent to ~/.cache/udt/udt-accent.rasi. deck-it reads both rather than restating the colours, so a scheme or wallpaper change reaches the tablet. """ +import json import re from pathlib import Path @@ -31,6 +32,9 @@ BORDER = re.compile(r"rgb\(\s*([0-9a-fA-F]{6})\s*\)") PALETTE_PATH = Path.home() / ".config" / "rofi" / "udt" / "palette.rasi" ACCENT_PATH = Path.home() / ".cache" / "udt" / "udt-accent.rasi" BORDER_PATH = Path.home() / ".cache" / "udt" / "udt-border.lua" +# Keystone's fonts page owns text sizes: deck-it's own override, else the base. +FONTS_PATH = Path.home() / ".config" / "keystone" / "fonts.json" +FONT_SIZE = 14 # px, the size deck.css was designed at # Catppuccin Macchiato, used before UDT has ever generated its files. FALLBACK = { @@ -58,8 +62,22 @@ def parse_border(text: str) -> list[str]: return ["#" + value.lower() for value in BORDER.findall(text)] -def css(colors: dict, accent: str | None, border: list[str] | None = None) -> str: +def parse_font_size(text: str) -> int | None: + """deck-it's px size from keystone's fonts.json, range-checked as quickshell does.""" + try: + data = json.loads(text) + px = (data.get("override") or {}).get("deckit", data.get("base")) + except (ValueError, AttributeError): + return None + if isinstance(px, (int, float)) and not isinstance(px, bool) and 8 <= px <= 40: + return round(px) + return None + + +def css(colors: dict, accent: str | None, border: list[str] | None = None, + font_size: int | None = None) -> str: lines = [":root {"] + lines.append(f" --udt-font-size: {font_size or FONT_SIZE}px;") lines += [f" --udt-{name}: {value};" for name, value in colors.items()] lines.append(f" --udt-accent: {accent or FALLBACK['accent']};") stops = border if border and len(border) >= 3 else [ @@ -86,4 +104,8 @@ def load() -> str: border = parse_border(BORDER_PATH.read_text()) except OSError: border = None - return css(colors, accent, border) + try: + font_size = parse_font_size(FONTS_PATH.read_text()) + except OSError: + font_size = None + return css(colors, accent, border, font_size) |
