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, use watch::on_theme_change (feature
watch): on each event call invalidate_caches() and re-read
crate::SystemTheme::from_system().
§Platform Behavior
- Linux: Checks
GTK_THEMEfor:darkor-dark; on KDE (with thekdefeature) readskdeglobals’ background luminance; thengsettingscolor-scheme(2-second timeout); thenkdeglobalson other desktops (withkde); finallygtk-3.0/settings.inigtk-application-prefer-dark-theme. - macOS: Reads
AppleInterfaceStyleviaNSUserDefaults(withmacosfeature) ordefaultssubprocess (without). - Windows: Checks foreground color luminance from
UISettingsvia BT.601 coefficients (requireswindowsfeature). - Other platforms / missing features: Returns
false(light).