Fix bazzite os detection

This commit is contained in:
Adrian Groh 2024-02-03 20:00:59 +01:00
parent 25ae2005c5
commit 4c02cf33ab
Signed by: Gobidev
GPG Key ID: 3AA3153E98B0D771
3 changed files with 17 additions and 6 deletions

1
Cargo.lock generated
View File

@ -827,6 +827,7 @@ dependencies = [
"glob",
"globset",
"libmacchina",
"os-release",
"pfetch-extractor",
"pfetch-logo-parser",
"which",

View File

@ -23,6 +23,7 @@ glob = "0.3.1"
which = "4.4.0"
libmacchina = "7.2.1"
crossterm = "0.27.0"
os-release = "0.1.0"
[profile.release]
strip = true

View File

@ -202,13 +202,22 @@ pub fn os(general_readout: &GeneralReadout) -> Option<String> {
.unwrap_or_default()
.contains("/bedrock/cross/")
{
Some("Bedrock Linux".to_string())
return Some("Bedrock Linux".to_string());
}
let content = os_release::OsRelease::new().ok()?;
let version = if !content.version.is_empty() {
content.version
} else {
match general_readout.distribution() {
Ok(distribution) => Some(distribution.replace(" TEMPLATE_VERSION_ID", "")),
Err(_) => None,
content.version_id
};
// check for Bazzite
if content.pretty_name.contains("Bazzite") {
return Some(format!("Bazzite {version}"));
}
if !version.is_empty() {
return Some(format!("{} {}", content.name, version));
}
Some(content.name)
}
_ => Some(general_readout.os_name().ok()?.replace("Unknown", "")),
}