retch-sysinfo 0.1.76

Cross-platform system and hardware information library (Linux, macOS, Windows) behind the retch fetcher
Documentation

retch-sysinfo

Crates.io Documentation License: GPL-3.0-or-later

A fast, concurrent, cross-platform hardware and system information gathering library for retch.

Extracted from the retch-cli binary to allow reuse as a standalone, zero-unnecessary-subprocess system probing library on Linux, macOS, and Windows.


Features

  • High-Performance & Concurrent: Probes run in parallel using scoped threads for minimal latency.
  • Minimal Subprocesses: Native Win32 FFI / WinRT COM on Windows, a direct binary D-Bus socket client on Linux, and Objective-C runtime / IOKit / SystemConfiguration FFI on macOS, instead of slow shell and interpreter forks. The few remaining spawns (for example btrfs, zpool, dmidecode, or a shell's own version query) run only when their field is requested.
  • Comprehensive Hardware & OS Detection:
    • CPU: Model name, physical/logical core count, P/E hybrid topology, frequency ranges, and cache sizes (L1/L2/L3).
    • GPU & VRAM: AMD GPUs (via libdrm amdgpu.ids & PCI IDs), NVIDIA, Intel, Apple Silicon, and the display-adapter registry keys on Windows.
    • Graphics APIs: Vulkan, OpenGL and OpenCL versions from the installed loaders.
    • I/O Throughput: Disk and network rates sampled over the collection window.
    • Displays: Multi-monitor resolution, refresh rates, and model/vendor names parsed from raw EDID binaries.
    • Memory & Storage: RAM capacity/usage, swap, physical DIMM speeds/types (SMBIOS/dmidecode), physical disks, NVMe/SATA/HDD identification, Btrfs subvolumes, and ZFS pools.
    • Network & Wi-Fi: Active default-route interface, local IPs, DNS domain/search scopes, Wi-Fi SSID/BSSID/channel/band/rate.
    • Peripherals: Audio servers/devices, Bluetooth controller status & connected devices, Battery health/cycle counts, Power adapters, Webcams/cameras, Gamepads/controllers, Input devices (Keyboards, Mice, Touchpads), and TPM versions.
    • Media & Player: Active media player name, playback status, and track metadata (artist, title, album).
    • Desktop Environment: DE, Window Manager, Login Manager, UI Theme, Icons, Cursor, Terminal (including Windows Terminal and its package version), Shell, and Weather.

Usage

Add retch-sysinfo to your Cargo.toml:

[dependencies]
retch-sysinfo = "0.1"

Basic Example

use retch_sysinfo::{CollectOptions, SystemInfo};

fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
    // Collect every field; set `fields: Some(vec![...])` to probe only some of them.
    let options = CollectOptions::default();

    // Probe system information concurrently.
    let info = SystemInfo::collect(options)?;

    println!("OS: {}", info.os);
    println!("CPU: {}", info.cpu);
    println!("Memory: {}", info.memory);
    if let Some(kernel) = &info.kernel {
        println!("Kernel: {kernel}");
    }
    Ok(())
}

This example is compiled as a doctest, so it cannot quietly stop compiling again.


Modules

retch-sysinfo provides modular subsystem detectors:

Module Description
audio Audio server (PipeWire, PulseAudio, ALSA, CoreAudio, WASAPI) and output devices
battery Battery status, charge level, health, time remaining, and power supplies
bios BIOS/firmware vendor, version, and release date
bluetooth Bluetooth adapter power state, name, and connected devices
btrfs Btrfs filesystem pools, allocation, and snapshot counts
camera Connected webcams and video capture devices
disk Filesystem mount usage and physical drive models (SSD/NVMe/HDD)
display Display connector resolution, refresh rate, and EDID model parsing
fetch Core orchestrator (SystemInfo, CollectOptions)
gamepad Connected gamepads, joysticks, and controllers
gpu GPU model detection and VRAM reporting
gpu_api Vulkan, OpenGL and OpenCL API versions via the platform loaders
input Input devices (keyboards, mice, touchpads, graphics tablets)
io Disk and network throughput sampling
media Active media player and playback track metadata
memory RAM usage, swap, and physical memory DIMM details
motherboard Motherboard / system vendor and model name
network Network interfaces, IP addresses, DNS domain, and Wi-Fi link status
packages Installed package counts (dpkg, rpm, pacman, flatpak, brew, etc.)
shell Current user shell and version
terminal Terminal emulator detection (including Windows Terminal's package version), window size, font and theme
theme Desktop theme, icons, cursor, and system fonts
weather Current weather conditions
wm Window manager and desktop environment detection
zfs ZFS storage pool health and capacity

License

This project is licensed under the GPL-3.0-or-later license. See the top-level repository for details.