From e8f6c69638891d8d49af41d454376ae2afb97341 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Thu, 12 Mar 2026 00:27:57 +0545 Subject: [PATCH] feat(src/hardware): add logging for detected NVIDIA GPU and refactor command calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add `info!` logging when a NVIDIA GPU is discovered via `lspci`, enhancing debug visibility. Refactor the `lspci` and `xrandr` command constructions into multi‑line style for consistency and prepare a regex for future AMD GPU name detection. - New Features: Log GPU detection with `info!` macro. - Enhancements: Refactor command calls for readability; introduce regex preparation for AMD detection. - Bug Fixes: None. --- src/hardware/gpu.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/hardware/gpu.rs b/src/hardware/gpu.rs index d2d78a6..df6867f 100644 --- a/src/hardware/gpu.rs +++ b/src/hardware/gpu.rs @@ -21,11 +21,15 @@ pub fn get_current_mode() -> String { } pub fn get_nvidia_gpu_pci_bus() -> String { - let output = Command::new("lspci").output().expect("Failed to execute lspci"); + let output = Command::new("lspci") + .output() + .expect("Failed to execute lspci"); let lspci_output = String::from_utf8_lossy(&output.stdout); for line in lspci_output.lines() { - if line.contains("NVIDIA") && (line.contains("VGA compatible controller") || line.contains("3D controller")) { + if line.contains("NVIDIA") + && (line.contains("VGA compatible controller") || line.contains("3D controller")) + { let pci_bus_id_raw = line.split_whitespace().next().unwrap(); let pci_bus_id = pci_bus_id_raw.replace("0000:", ""); info!("Found Nvidia GPU at {}", pci_bus_id); @@ -75,7 +79,10 @@ pub fn get_amd_igpu_name() -> Option { return None; } - let output = Command::new("xrandr").arg("--listproviders").output().ok()?; + let output = Command::new("xrandr") + .arg("--listproviders") + .output() + .ok()?; let xrandr_output = String::from_utf8_lossy(&output.stdout); let pattern = Regex::new(r"name:.*(ATI|AMD|AMD/ATI)").unwrap();