ltk::theme

Module assets

Source
Expand description

Theme asset resolution: wallpapers, lockscreens, branding logos, app icons, launcher icon, and the SVG rasterisation pipeline (with process-wide cache) that the canvas consumes.

Functions§

  • Path to app-default.svg inside the active theme’s icon directory. Returns None when the document has no on-disk root or the file is absent.
  • Path to the named app icon SVG inside the active theme’s icons/apps/ directory. name is the bare stem (e.g. "firefox", "calculator") without the .svg extension. Returns None when the active document has no on-disk root or the file does not exist.
  • Resolve a branding asset (launcher logo, wallpaper, lockscreen, …) against the active theme’s branding/ tree. Tries three candidate paths in order and returns the first one that exists on disk:
  • Resolve a branded image asset, preferring a raster variant (WebP / PNG / JPEG) over the canonical SVG. Tries [branding_raster(name, sw, sh)] first; on None (no raster files at all under branding/{mode}/{name}/) falls back to [branding_asset(name, "svg")].
  • Resolve a raster variant of a branded asset for the given surface dimensions. Looks under branding/{mode}/{name}/ (with the standard mode → opposite-mode → no-mode fallback chain on the directory), parses each filename as WIDTHxHEIGHT.<ext> where <ext> is webp, png, jpg, or jpeg. Returns the best match in the first existing directory:
  • Decode a UTF-8 SVG document into a premultiplied RGBA8 pixmap of the requested longest-edge size in physical pixels. The shorter edge is scaled proportionally so the icon’s aspect ratio is preserved; the returned (width, height) reflect the final pixmap.
  • Resolve a theme-relative icon name to an absolute path inside the active theme’s icons/catalogue/ tree.
  • Rasterise a theme icon to a premultiplied RGBA8 pixmap.
  • Path to the launcher-logo SVG for the currently active mode. Resolves through branding_asset using the convention branding/{mode}/launcher.svg, with the standard mode → opposite-mode → no-mode fallback chain.
  • The active mode’s lockscreen / greeter wallpaper. Same resolution strategy as wallpaper: explicit theme.json declaration first, otherwise branding/{mode}/lockscreen.svg via branding_asset. Use branding_image( "lockscreen", sw, sh ) for the size-aware raster lookup.
  • Path to the brand logo SVG for the currently active mode. Convention: branding/{mode}/logo/logo.svg. The “main” logo — usually the wordmark variant a shell would put in an “About” dialog or a splash. Pair with logo_square / logo_horizontal when the surface dictates a different aspect ratio.
  • Path to the horizontal (wordmark) brand logo SVG for the currently active mode. Convention: branding/{mode}/logo/horizontal.svg. Use when there is meaningful horizontal space — header bars, menu bars, “About” dialogs, sign-in screens. Same fallback chain as logo.
  • Path to the square (1:1) brand logo SVG for the currently active mode. Convention: branding/{mode}/logo/square.svg. Use when the surface is roughly square — app icons, login avatars, splash screens, lockscreen brand badges. Same fallback chain as logo.
  • Re-tint a symbolic RGBA icon: replace every pixel’s RGB with tint while keeping the source alpha (weighted by tint.a).
  • The active mode’s homescreen / shell wallpaper. Prefers an explicit declaration in theme.json; when absent, falls back to the convention path branding/{mode}/wallpaper.svg via branding_asset (with mode → opposite-mode → no-mode fallback). Returns None when neither source resolves to an existing file.