finish up gpu stuff

This commit is contained in:
SadlyNotSappho 2023-06-02 12:31:57 -07:00
parent 284cf2608b
commit 3c993ee756
6 changed files with 7 additions and 4 deletions

0
.gitignore vendored Normal file → Executable file
View File

0
Cargo.toml Normal file → Executable file
View File

0
LICENSE Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

6
src/lib.rs Normal file → Executable file
View File

@ -112,15 +112,15 @@ pub fn get_cpu() -> HashMap<String, u16> {
parsed parsed
} }
pub fn get_gpu() { pub fn get_gpu() -> Vec<String> {
let binding = std::process::Command::new("lspci").output().expect("lspci failed"); let binding = std::process::Command::new("lspci").output().expect("lspci failed");
let lspci = String::from_utf8_lossy(&binding.stdout).to_string(); let lspci = String::from_utf8_lossy(&binding.stdout).to_string();
let mut vga = vec![]; let mut vga = vec![];
for line in lspci.lines() { for line in lspci.lines() {
if line.contains("VGA") { if line.contains("VGA") {
vga.push(line.split(":").collect::<Vec<&str>>()[2].trim()) vga.push(line.split(":").collect::<Vec<&str>>()[2].trim().to_string())
} }
} }
println!("{:?}", vga); vga
} }

5
src/main.rs Normal file → Executable file
View File

@ -23,8 +23,11 @@ fn main() {
.collect::<Vec<String>>() .collect::<Vec<String>>()
.join(", "); .join(", ");
println!( println!(
"CPU Name{}: {}", "CPU{}: {}",
if cpus.len() == 1 { "" } else { "s" }, if cpus.len() == 1 { "" } else { "s" },
cpu_name cpu_name
); );
let gpu_name = gpus.join(", ");
println!("GPU{}: {}", if gpus.len() == 1 {""} else {"s"}, gpu_name);
} }