feat(robin): M1 System Presence — journald/kmsg/inotify watcher, pattern classifier, tray badge, chat panel #2
1 changed files with 19 additions and 4 deletions
|
|
@ -7,9 +7,7 @@ pub fn detect() -> String {
|
||||||
pub fn distro_family(id: &str) -> &'static str {
|
pub fn distro_family(id: &str) -> &'static str {
|
||||||
match id {
|
match id {
|
||||||
"arch" | "cachyos" | "endeavouros" | "manjaro" | "garuda" => "arch",
|
"arch" | "cachyos" | "endeavouros" | "manjaro" | "garuda" => "arch",
|
||||||
"debian" | "ubuntu" | "linuxmint" | "pop" | "elementary" | "kali" => {
|
"debian" | "ubuntu" | "linuxmint" | "mint" | "pop" | "elementary" | "kali" => "debian",
|
||||||
"debian"
|
|
||||||
}
|
|
||||||
"fedora" | "rhel" | "centos" | "rocky" | "alma" => "fedora",
|
"fedora" | "rhel" | "centos" | "rocky" | "alma" => "fedora",
|
||||||
"opensuse" | "opensuse-tumbleweed" | "opensuse-leap" => "opensuse",
|
"opensuse" | "opensuse-tumbleweed" | "opensuse-leap" => "opensuse",
|
||||||
_ => "unknown",
|
_ => "unknown",
|
||||||
|
|
@ -22,7 +20,13 @@ fn parse_id(content: &str) -> String {
|
||||||
.find_map(|line| {
|
.find_map(|line| {
|
||||||
let (key, val) = line.split_once('=')?;
|
let (key, val) = line.split_once('=')?;
|
||||||
if key.trim() == "ID" {
|
if key.trim() == "ID" {
|
||||||
Some(val.trim().trim_matches('"').to_lowercase())
|
let raw = val.trim();
|
||||||
|
let unquoted = raw
|
||||||
|
.strip_prefix('"')
|
||||||
|
.and_then(|s| s.strip_suffix('"'))
|
||||||
|
.or_else(|| raw.strip_prefix('\'').and_then(|s| s.strip_suffix('\'')))
|
||||||
|
.unwrap_or(raw);
|
||||||
|
Some(unquoted.to_lowercase())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
@ -70,4 +74,15 @@ mod tests {
|
||||||
fn distro_family_unknown() {
|
fn distro_family_unknown() {
|
||||||
assert_eq!(distro_family("slackware"), "unknown");
|
assert_eq!(distro_family("slackware"), "unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parses_single_quoted_id() {
|
||||||
|
let content = "ID='arch'\nPRETTY_NAME='Arch Linux'\n";
|
||||||
|
assert_eq!(parse_id(content), "arch");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn distro_family_mint_legacy() {
|
||||||
|
assert_eq!(distro_family("mint"), "debian");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue