Skip to main content

from_system

Function from_system 

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

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

§Platform Behavior

  • macOS: Calls from_macos() when the macos feature is enabled. Reads both light and dark variants via NSAppearance.
  • Linux (KDE): Calls from_kde() when XDG_CURRENT_DESKTOP contains “KDE” and the kde feature is enabled.
  • Linux (other): Returns the bundled Adwaita preset. For live GNOME portal data, call from_gnome() directly (requires portal-tokio or portal-async-io feature).
  • Windows: Calls from_windows() when the windows feature is enabled.
  • 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.