pub fn system_icon_theme() -> Result<String>Expand description
Detect the icon theme name for the current platform (cached).
Returns the name of the icon theme that provides the actual icon files:
- macOS / iOS:
"sf-symbols"(no user-configurable icon theme) - Windows:
"segoe-fluent"(no user-configurable icon theme) - Linux: DE-specific detection (e.g.,
"breeze-dark","Adwaita") - Other: an error; there is no icon theme to detect
On Linux, the detection method depends on the desktop environment, the
one the reader is chosen by: an unrecognised XDG_CURRENT_DESKTOP counts
as the desktop of its portal backend (once a system read such as
SystemTheme::from_system has asked
it, with the portal feature), else as KDE where the user’s kdeglobals
exists (with the kde feature):
- KDE:
[Icons] Themeof kdeglobals as KConfig cascades it, the KDE reader’s read (with thekdefeature); without the feature, fromkdeglobals, then fromkdedefaults/kdeglobals - GNOME/Budgie:
gsettings get org.gnome.desktop.interface icon-theme - Cinnamon:
gsettings get org.cinnamon.desktop.interface icon-theme - XFCE:
xfconf-query -c xsettings -p /Net/IconThemeName - MATE:
gsettings get org.mate.interface icon-theme - LXQt: reads
icon_themefrom~/.config/lxqt/lxqt.conf - Unknown (still): tries KDE, then GNOME gsettings
No theme stands in for one that cannot be detected: the error says why, and what to do without a theme is the caller’s decision.
Delegates to DetectionContext::icon_theme()
which caches the outcome, a failure included, and supports per-field
invalidation via invalidate_caches().
§Errors
Error::ReaderFailedwithreader"icon-theme"on Linux when no source names a theme. Its message names each source tried and why it gave no name: the config directory could not be resolved (no absolute$XDG_CONFIG_HOME, and$HOMEunset or empty), a file could not be read or lacks the key, or a command was not found, exited unsuccessfully, printed no name or did not finish within 2 s. On an unrecognised desktop it names both attempts, KDE’s and GNOME’s.Error::PlatformUnsupportedon a platform other than Linux, macOS, iOS and Windows.
§Examples
use native_theme::detect::system_icon_theme;
match system_icon_theme() {
// On a KDE system with Breeze Dark: "breeze-dark"; on macOS: "sf-symbols"
Ok(theme) => println!("icon theme: {theme}"),
Err(e) => println!("no icon theme: {e}"),
}