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:
- KDE: reads
[Icons] Themefromkdeglobals, 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: 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 ($XDG_CONFIG_HOMEand$HOMEboth unset or empty), a file could not be read or lacks the key, or a command was not found, exited unsuccessfully or printed no name. 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::theme::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}"),
}