// Memory let total_mem = sys.total_memory() / (1024 * 1024); let used_mem = sys.used_memory() / (1024 * 1024); let memory = format!("{} MiB / {} MiB", used_mem, total_mem);
// Shell let shell = env::var("SHELL").unwrap_or_else(|_| "unknown".to_string()) .split('/').last().unwrap_or("unknown").to_string(); new desktop command
// OS & Kernel let os = whoami::distro().unwrap_or_else(|| "Unknown".to_string()); let host = whoami::hostname(); let kernel = sys.kernel_version().unwrap_or_else(|| "Unknown".to_string()); // Memory let total_mem = sys
// CPU let cpu_name = sys.global_cpu_info().brand().trim().to_string(); let cpu_cores = sys.physical_core_count().unwrap_or(1); let cpu = format!("{} ({} cores)", cpu_name, cpu_cores); let host = whoami::hostname()
// Disk (root partition) let mut disk_info = "N/A".to_string(); for disk in sys.disks() { if cfg!(target_os = "windows") && disk.mount_point().to_str() == Some("C:") || cfg!(target_os = "linux") && disk.mount_point().to_str() == Some("/") || cfg!(target_os = "macos") && disk.mount_point().to_str() == Some("/") { let total = disk.total_space() / (1024 * 1024 * 1024); let available = disk.available_space() / (1024 * 1024 * 1024); let used = total - available; disk_info = format!("{} GiB / {} GiB", used, total); break; } }
Below is the complete source code, build instructions, and usage examples. // qfetch - A fast, modern system information tool for the desktop // Command: qfetch [OPTIONS] use std::process::Command; use std::env; use sysinfo::System, SystemExt, CpuExt, DiskExt; use whoami;