use std::fs; // use std::fmt; use std::path::Path; fn main() { let hwmon_path = fs::read_dir(Path::new("/sys/devices/pci0000:00/0000:00:18.3/hwmon/"))?.next().unwrap()?.path(); // let temp_raw = fs::read_to_string(hwmon_path.join("temp1_input"))?; let temperature = fs::read_to_string(hwmon_path.join("temp1_input"))?.trim_end().parse::()? / 1000.0; let filename_usage = format!("{}/gpu_busy_percent", dir); let usage = format!("{}", fs::read_to_string(filename_usage)?.trim_end()); // No need to convert from ASCII to int to ASCII print!("{}%\r{}℃\n", usage, temperature); }