use indexmap::{IndexMap, indexmap};
use os_info::Type;
use serde::{Deserialize, Serialize};
#[derive(Clone, Deserialize, Serialize)]
#[cfg_attr(
feature = "config-schema",
derive(schemars::JsonSchema),
schemars(deny_unknown_fields)
)]
#[serde(default)]
pub struct OSConfig<'a> {
pub format: &'a str,
pub style: &'a str,
pub symbols: IndexMap<Type, &'a str>,
pub disabled: bool,
}
impl<'a> OSConfig<'a> {
pub fn get_symbol(&self, key: Type) -> Option<&'a str> {
self.symbols.get(&key).copied()
}
}
impl Default for OSConfig<'_> {
fn default() -> Self {
Self {
format: "[$symbol]($style)",
style: "bold white",
symbols: indexmap! {
Type::AIX => "โฟ ",
Type::Alpaquita => "๐ ",
Type::AlmaLinux => "๐ ",
Type::Alpine => "๐๏ธ ",
Type::ALTLinux => "โถ ",
Type::Amazon => "๐ ",
Type::Android => "๐ค ",
Type::AOSC => "๐ฑ ",
Type::Arch => "๐๏ธ ",
Type::Artix => "๐๏ธ ",
Type::Bluefin => "๐ ",
Type::CachyOS => "๐๏ธ ",
Type::CentOS => "๐ ",
Type::Debian => "๐ ",
Type::Elementary => "๐ ",
Type::DragonFly => "๐ ",
Type::Emscripten => "๐ ",
Type::EndeavourOS => "๐ ",
Type::Fedora => "๐ฉ ",
Type::FreeBSD => "๐ ",
Type::Garuda => "๐ฆ
",
Type::Gentoo => "๐๏ธ ",
Type::HardenedBSD => "๐ก๏ธ ",
Type::Illumos => "๐ฆ ",
Type::Ios => "๐ฑ ",
Type::InstantOS => "โฒ๏ธ ",
Type::Kali => "๐ ",
Type::Linux => "๐ง ",
Type::Mabox => "๐ฆ ",
Type::Macos => "๐ ",
Type::Manjaro => "๐ฅญ ",
Type::Mariner => "๐ ",
Type::MidnightBSD => "๐ ",
Type::Mint => "๐ฟ ",
Type::NetBSD => "๐ฉ ",
Type::NixOS => "โ๏ธ ",
Type::Nobara => "๐ฉ ",
Type::OpenBSD => "๐ก ",
Type::OpenCloudOS => "โ๏ธ ",
Type::openEuler => "๐ฆ ",
Type::openSUSE => "๐ฆ ",
Type::OracleLinux => "๐ฆด ",
Type::PikaOS => "๐ค ",
Type::Pop => "๐ญ ",
Type::Raspbian => "๐ ",
Type::Redhat => "๐ฉ ",
Type::RedHatEnterprise => "๐ฉ ",
Type::RockyLinux => "๐ ",
Type::Redox => "๐งช ",
Type::Solus => "โต ",
Type::SUSE => "๐ฆ ",
Type::Ubuntu => "๐ฏ ",
Type::Ultramarine => "๐ท ",
Type::Unknown => "โ ",
Type::Uos => "๐ฒ ",
Type::Void => "๎ ",
Type::Windows => "๐ช ",
Type::Zorin => "๐น ",
},
disabled: true,
}
}
}