1use std::borrow::Cow;
7use std::sync::Mutex;
8
9pub const COSMIC: &str = crate::cosmic_theme::DEFAULT_ICON_THEME;
10
11static OVERRIDE: Mutex<Option<Cow<'static, str>>> = Mutex::new(None);
12
13#[must_use]
16#[allow(clippy::missing_panics_doc)]
17#[inline]
18pub fn default() -> String {
19 let override_theme = OVERRIDE.lock().unwrap();
20 if let Some(theme) = override_theme.as_ref() {
21 return theme.to_string();
22 }
23 drop(override_theme);
24
25 let theme = crate::theme::active().cosmic().icon_theme.clone();
26 if theme.is_empty() {
27 COSMIC.to_string()
28 } else {
29 theme
30 }
31}
32
33#[allow(clippy::missing_panics_doc)]
38#[cold]
39pub fn set_default(name: impl Into<Cow<'static, str>>) {
40 let name = name.into();
41 *OVERRIDE.lock().unwrap() = if name.is_empty() { None } else { Some(name) };
42}
43
44#[allow(clippy::missing_panics_doc)]
46#[cold]
47pub fn reset_default() {
48 *OVERRIDE.lock().unwrap() = None;
49}