use cosmic_config::{Config, ConfigGet, CosmicConfigEntry};
pub const THEME_MODE_ID: &str = "com.system76.CosmicTheme.Mode";
#[derive(
Debug, Clone, Copy, PartialEq, Eq, cosmic_config::cosmic_config_derive::CosmicConfigEntry,
)]
#[version = 1]
pub struct ThemeMode {
pub is_dark: bool,
pub auto_switch: bool,
}
impl Default for ThemeMode {
fn default() -> Self {
Self {
is_dark: true,
auto_switch: false,
}
}
}
impl ThemeMode {
pub fn is_dark(config: &Config) -> Result<bool, cosmic_config::Error> {
config.get::<bool>("is_dark")
}
pub const fn version() -> u64 {
Self::VERSION
}
pub fn config() -> Result<Config, cosmic_config::Error> {
Config::new(THEME_MODE_ID, Self::VERSION)
}
}