Skip to main content

system_is_dark

Function system_is_dark 

Source
pub fn system_is_dark() -> bool
Expand 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). The result is cached after the first call using OnceLock.

ยงPlatform Behavior

  • Linux: Queries gsettings for color-scheme; falls back to KDE kdeglobals background luminance (with kde feature).
  • macOS: Reads AppleInterfaceStyle from global user defaults; returns true when the value is "Dark" (key absent in light mode).
  • Windows: Checks foreground color luminance from UISettings via BT.601 coefficients (requires windows feature).
  • Other platforms / missing features: Returns false (light).