add architecture (fuck this) and kernel version detection

This commit is contained in:
SadlyNotSappho 2023-03-14 15:19:44 -07:00
parent 16f3dcce8e
commit 0da9c61362
2 changed files with 20 additions and 3 deletions

View File

@ -4,7 +4,7 @@ use dotenv_parser::parse_dotenv;
pub fn get_os() -> String { pub fn get_os() -> String {
let os_release = read_to_string("/etc/os-release").unwrap(); let os_release = read_to_string("/etc/os-release").unwrap();
let parsed = parse_dotenv(&os_release).unwrap(); let parsed = parse_dotenv(&os_release).unwrap();
parsed.get("PRETTY_NAME").unwrap().clone() parsed.get("PRETTY_NAME").unwrap().clone().trim().to_string()
} }
pub fn get_cpu() { pub fn get_cpu() {
@ -13,3 +13,17 @@ pub fn get_cpu() {
println!("{}", &lscpu) println!("{}", &lscpu)
} }
pub fn get_arch() -> String {
let binding = std::process::Command::new("uname").arg("-m").output().expect("uname failed");
let arch = String::from_utf8_lossy(&binding.stdout);
arch.to_string().trim().to_string()
}
pub fn get_kernel_ver() -> String {
let binding = std::process::Command::new("uname").arg("-s").output().expect("uname failed");
let ver = String::from_utf8_lossy(&binding.stdout);
ver.to_string().trim().to_string()
}

View File

@ -1,5 +1,8 @@
use gayfetch::{get_os, get_cpu}; use gayfetch::*;
fn main() { fn main() {
let os = get_os(); let os = get_os();
let cpu = get_cpu(); let arch = get_arch();
let kernel = get_kernel_ver();
println!("OS Name: {os}\nArchitecture: {arch}\nKernel Version: {kernel}");
} }