cosmic/
icon_theme.rs

1// Copyright 2023 System76 <info@system76.com>
2// SPDX-License-Identifier: MPL-2.0
3
4//! Select the preferred icon theme.
5
6use std::borrow::Cow;
7use std::sync::Mutex;
8
9pub const COSMIC: &str = "Cosmic";
10
11pub(crate) static DEFAULT: Mutex<Cow<'static, str>> = Mutex::new(Cow::Borrowed(COSMIC));
12
13/// The fallback icon theme to search if no icon theme was specified.
14#[must_use]
15#[allow(clippy::missing_panics_doc)]
16#[inline]
17pub fn default() -> String {
18    DEFAULT.lock().unwrap().to_string()
19}
20
21/// Set the fallback icon theme to search when loading system icons.
22#[allow(clippy::missing_panics_doc)]
23#[cold]
24pub fn set_default(name: impl Into<Cow<'static, str>>) {
25    *DEFAULT.lock().unwrap() = name.into();
26}