diff --git a/src/about.rs b/src/about.rs index 99941905..b0703729 100644 --- a/src/about.rs +++ b/src/about.rs @@ -1,6 +1,12 @@ -use std::{env, path::Path}; +use std::{ + env, + io::BufRead, + path::Path, + process::{Command, Stdio}, +}; use adw::prelude::*; +use anyhow::Result; use gettextrs::gettext; use gst::prelude::*; use gtk::glib; @@ -63,12 +69,53 @@ fn release_notes() -> &'static str { "# } +fn cpu_model() -> Result { + let output = Command::new("lscpu") + .stdout(Stdio::piped()) + .spawn()? + .wait_with_output()?; + + for res in output.stdout.lines() { + let line = res?; + + if line.contains("Model name:") { + if let Some((_, value)) = line.split_once(':') { + return Ok(value.trim().to_string()); + } + } + } + + Ok("".into()) +} + +fn gpu_model() -> Result { + let output = Command::new("lspci") + .stdout(Stdio::piped()) + .spawn()? + .wait_with_output()?; + + for res in output.stdout.lines() { + let line = res?; + + if line.contains("VGA") { + if let Some(value) = line.splitn(3, ':').last() { + return Ok(value.trim().to_string()); + } + } + } + + Ok("".into()) +} + fn debug_info() -> String { let is_flatpak = Path::new("/.flatpak-info").exists(); let is_experimental_mode = *IS_EXPERIMENTAL_MODE; let language_names = glib::language_names().join(", "); + let cpu_model = cpu_model().unwrap_or_else(|e| format!("<{}>", e)); + let gpu_model = gpu_model().unwrap_or_else(|e| format!("<{}>", e)); + let distribution = glib::os_info("PRETTY_NAME").unwrap_or_else(|| "".into()); let desktop_session = env::var("DESKTOP_SESSION").unwrap_or_else(|_| "".into()); let display_server = env::var("XDG_SESSION_TYPE").unwrap_or_else(|_| "".into()); @@ -101,6 +148,9 @@ fn debug_info() -> String { - Language: {language_names} +- CPU: {cpu_model} +- GPU: {gpu_model} + - Distribution: {distribution} - Desktop Session: {desktop_session} - Display Server: {display_server}