pub fn system_is_dark() -> boolExpand description
Detect whether the system is using a dark color scheme.
Uses synchronous, platform-specific checks so the result is available immediately at window creation time (before any async portal response).
§Caching
The result is cached after the first call and reused on subsequent calls.
Call invalidate_caches() to clear the cached value so the next call
re-queries the OS. For a fresh reading without affecting the cache, use
detect_is_dark() instead.
For live dark-mode tracking, subscribe to OS appearance-change events
(D-Bus SettingChanged on Linux, NSAppearance KVO on macOS,
UISettings.ColorValuesChanged on Windows) and call SystemTheme::from_system()
to get a fresh SystemTheme with updated resolved variants.
§Platform Behavior
- Linux: Checks
GTK_THEMEenv var for:darksuffix or-darkin name; queriesgsettingsforcolor-scheme(with 2-second timeout); falls back to KDEkdeglobalsbackground luminance (withkdefeature); readsgtk-3.0/settings.iniforgtk-application-prefer-dark-theme=1as final fallback. - macOS: Reads
AppleInterfaceStyleviaNSUserDefaults(withmacosfeature) ordefaultssubprocess (without). - Windows: Checks foreground color luminance from
UISettingsvia BT.601 coefficients (requireswindowsfeature). - Other platforms / missing features: Returns
false(light).