cosmic/
icon_theme.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright 2023 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0

//! Select the preferred icon theme.

use std::borrow::Cow;
use std::sync::Mutex;

pub const COSMIC: &str = "Cosmic";

pub(crate) static DEFAULT: Mutex<Cow<'static, str>> = Mutex::new(Cow::Borrowed(COSMIC));

/// The fallback icon theme to search if no icon theme was specified.
#[must_use]
#[allow(clippy::missing_panics_doc)]
pub fn default() -> String {
    DEFAULT.lock().unwrap().to_string()
}

/// Set the fallback icon theme to search when loading system icons.
#[allow(clippy::missing_panics_doc)]
pub fn set_default(name: impl Into<Cow<'static, str>>) {
    *DEFAULT.lock().unwrap() = name.into();
}