Skip to main content

from_system

Function from_system 

Source
pub fn from_system() -> Result<SystemTheme>
Expand description

Read the current system theme, auto-detecting the platform and desktop environment.

Runs the full OS-first pipeline: OS reader -> platform preset merge -> resolve -> validate -> SystemTheme with both light and dark ResolvedTheme variants.

§Platform Behavior

  • macOS: Calls from_macos() when the macos feature is enabled. Reads both light and dark variants via NSAppearance, merges with macos-sonoma preset.
  • Linux (KDE): Calls from_kde() when XDG_CURRENT_DESKTOP contains “KDE” and the kde feature is enabled, merges with kde-breeze preset.
  • Linux (other): Uses the adwaita preset. For live GNOME portal data, use from_system_async() (requires portal-tokio or portal-async-io feature).
  • Windows: Calls from_windows() when the windows feature is enabled, merges with windows-11 preset.
  • Other platforms: Returns Error::Unsupported.

§Errors

  • Error::Unsupported if the platform has no reader or the required feature is not enabled.
  • Error::Unavailable if the platform reader cannot access theme data.