fix: linux, window, workaround, mint, mate (#10146)

* refact: linux, window, workaround, mint, mate

Signed-off-by: fufesou <linlong1266@gmail.com>

* refact: case insensitive

Signed-off-by: fufesou <linlong1266@gmail.com>

---------

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou
2024-12-03 01:02:41 +08:00
committed by GitHub
parent b8d36b6558
commit bd0a33e467
6 changed files with 161 additions and 17 deletions

View File

@@ -13,22 +13,35 @@ pub const XDG_CURRENT_DESKTOP: &str = "XDG_CURRENT_DESKTOP";
pub struct Distro {
pub name: String,
pub id: String,
pub version_id: String,
}
impl Distro {
fn new() -> Self {
// to-do:
// 1. Remove `run_cmds`, read file once
// 2. Add more distro infos
let name = run_cmds("awk -F'=' '/^NAME=/ {print $2}' /etc/os-release")
.unwrap_or_default()
.trim()
.trim_matches('"')
.to_string();
let id = run_cmds("awk -F'=' '/^ID=/ {print $2}' /etc/os-release")
.unwrap_or_default()
.trim()
.trim_matches('"')
.to_string();
let version_id = run_cmds("awk -F'=' '/^VERSION_ID=/ {print $2}' /etc/os-release")
.unwrap_or_default()
.trim()
.trim_matches('"')
.to_string();
Self { name, version_id }
Self {
name,
id,
version_id,
}
}
}