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 using OnceLock and never
refreshed. If the user toggles dark mode while the app is running,
this function will return stale data. Use detect_is_dark() instead
for a fresh reading suitable for polling or change tracking.
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: Queries
gsettingsforcolor-schemevia subprocess; falls back to KDEkdeglobalsbackground luminance (withkdefeature). - macOS: Reads
AppleInterfaceStyleviaNSUserDefaults(withmacosfeature) ordefaultssubprocess (without). - Windows: Checks foreground color luminance from
UISettingsvia BT.601 coefficients (requireswindowsfeature). - Other platforms / missing features: Returns
false(light).