ltk

Module theme

Source
Expand description

Theming for ltk-based applications.

A theme is a directory on disk holding a theme.json and any supporting assets (wallpapers, fonts, …). The JSON declares light and dark modes — each with its own slot table plus wallpaper, lockscreen, launcher and window-controls blocks — plus a shared fonts registry. The shell picks which mode is active via ThemeMode.

§On-disk layout

/usr/share/ltk/themes/<id>/             (system overlay, lower priority)
~/.local/share/ltk/themes/<id>/         (user overlay,   higher priority)
    theme.json
    background-light.png
    background-dark.png
    fonts/
        Sora-Regular.ttf

Paths inside theme.json are interpreted relative to the theme’s directory and are eagerly resolved to absolute paths at load time.

§Process-wide active state

The active theme is published process-wide so widgets can consult their colours without every caller threading the palette through their own state. Use set_active_document / set_active_mode to change it, and active_document / active_mode / active_theme_id to read it back. Per-slot shorthand accessors (color, paint(), surface(), palette(), …) cover the common patterns without going through the full document.

There is no in-code fallback: if ensure_active cannot locate the default theme in any search path, the process aborts with a message pointing at the ltk-theme-default Debian package (it Provides: ltk-theme) or at the LTK_THEMES_DIR environment variable for development installations.

Re-exports§

Modules§

  • Slot-typed shorthand accessors against the active theme document.
  • Process-wide active theme state.
  • Theme asset resolution: wallpapers, lockscreens, branding logos, app icons, launcher icon, and the SVG rasterisation pipeline (with process-wide cache) that the canvas consumes.
  • The top-level theme document: metadata, fonts block and per-mode slots.
  • Error type returned by theme loading and parsing.
  • Runtime font registry: families → (weight, style) → fontdue::Font.
  • Font family definitions as declared by the theme document.
  • CPU-side gradient sampling and LUT baking.
  • Paint primitives: the “what do we fill a shape with” side of theming.
  • The eight-slot semantic Palette every widget speaks in terms of, plus the derived WindowControlsSpec fallback used when a theme document omits the explicit window_controls block.
  • Theme preference / mode types and per-asset specification structs.
  • Theme directory search paths and the font-registry builder that walks the active document’s font block.
  • Shadow primitives: outer drop shadows, inner inset shadows, and the blend modes used to composite them.
  • The slot-typed lookup table that backs the new theme API.
  • Composite surfaces: fill + outer shadows + inset shadows.
  • Typography tokens: a resolved text style (family + weight + size + …) as the theme knows it.
  • Typography scale used by the default theme.