Appearance
Reading the colour scheme
Section titled “Reading the colour scheme”from uda import Uda
with Uda() as uda: print(uda.theme) # 'dark' | 'light' | 'unknown'const { Uda } = require('./uda');console.log(new Uda().theme);let mode = uda_platform_linux::LinuxAppearanceManager::new().detect_theme()?;'unknown' is a legitimate answer: a compositor with no colour-scheme concept (a bare window manager, some Wayland tilers) genuinely cannot tell, and guessing would be worse. Treat it as “cannot tell” and let the user choose.
Reading the accent colour
Section titled “Reading the accent colour”color = uda.accent_color # (r, g, b, a) or NoneThe four channels are written into a caller-supplied buffer, and a platform with no system-wide accent concept (KDE, XFCE, most Wayland tilers) leaves the slot untouched and still returns success. A zeroed slot therefore means “no accent”, which is not an error — check the returned status only for hard failures.
Following the system
Section titled “Following the system”UDA does not provide a change listener; the read is a snapshot. To follow the user’s choice, poll detect_theme at a sensible interval:
import timefrom uda import Uda
with Uda() as uda: last = None while True: theme = uda.theme if theme != last: apply_theme(theme) last = theme time.sleep(1.0)If your toolkit already handles theme changes, prefer its own signal — a UI framework that emits a theme-changed event is both cheaper and more accurate than polling.
Per-desktop behaviour
Section titled “Per-desktop behaviour”| Desktop | Source | Notes |
|---|---|---|
| GNOME 42+ | org.freedesktop.portal.Settings |
the modern standard answer |
| KDE Plasma 5 / 6 | org.freedesktop.portal.Settings → kreadconfig6 / kreadconfig5 reading Colors:Scheme |
full support |
| XFCE | xfconf-query -c xsettings -p /Net/ThemeName |
no system-wide scheme; often answers unknown |
| Hyprland / Sway | GSettings | tiling composers rarely publish a scheme |
| Windows 10 / 11 | Registry AppsUseLightTheme |
full support, including live changes |
Note that the accent colour is a separate query from the colour scheme, with its own support profile:
| Platform | Accent colour |
|---|---|
| Windows | ✅ registry HKCU\...\DWM\AccentColor, unpacked to RGBA |
| GNOME | ✅ gsettings get org.gnome.desktop.interface accent-color |
| KDE / XFCE | best-effort; returns None when absent |
| Wayland tilers | ❌ no system-wide accent concept |
The capability bit Capability::DETECT_THEME says whether any source answered. Capability::FOLLOW_SYSTEM_THEME is defined in the flag set but is not currently set by any backend, because no backend publishes change events yet; do not gate a “follow system” toggle on it.
Design note
Section titled “Design note”Reading the colour scheme is a read-only, side-effect-free query with no D-Bus write, so a UI can call it freely — on startup, on every window shown, or on every signal. It never modifies the desktop’s own theme; it only observes.
See also
Section titled “See also”- Capability and fallback — how the tier chain resolves here
- Platform support — the per-desktop matrix
