-
Notifications
You must be signed in to change notification settings - Fork 0
Workspace Architecture
Ken Tobias edited this page Jun 10, 2026
·
7 revisions
retch is structured as a Cargo workspace to keep the codebase modular, clean, and reusable.
.
├── Cargo.toml # Root workspace config
├── Cargo.lock
├── Justfile # Command runner scripts
├── README.md
├── docs/ # Manual pages & documentation
├── src/ # retch-cli source code
│ ├── cli.rs # Clap arguments and flags
│ ├── config.rs # TOML parsing & merge logic
│ ├── display.rs # Output formatting and rendering
│ ├── fetch.rs # Thin re-export shim → retch_sysinfo::fetch
│ ├── gpu.rs # Thin re-export shim → retch_sysinfo::gpu
│ ├── logo.rs # Logo rendering (Kitty/iTerm2/Sixel/Chafa/ASCII)
│ ├── theme.rs # Theme definitions and color resolution
│ └── main.rs # Entry point and config creation
└── crates/
└── sysinfo/ # retch-sysinfo subcrate (standalone library)
├── Cargo.toml
└── src/
├── lib.rs # Public API surface
├── fetch.rs # Parallel scoped-thread fetching pipeline
├── gpu.rs # GPU detection and PCI ID lookup
├── display.rs # Display detection and EDID parsing
├── network.rs # Network interfaces, IP resolution, and Wi-Fi
├── audio.rs # Audio server and device detection
├── bluetooth.rs # Bluetooth controller state and connected devices
└── battery.rs # Cross-platform battery implementation
The root Cargo.toml specifies the workspace members:
[workspace]
members = [
".",
"crates/sysinfo",
]The main binary command-line interface. It handles terminal detection, configuration parsing, logo rendering, and output formatting. The system information fetching and hardware detection logic has been extracted into retch-sysinfo; src/fetch.rs and src/gpu.rs are thin re-export shims so all existing call sites continue to compile unchanged.
The core system information library. All hardware detection and slow external queries live here, executed concurrently using std::thread::scope.
-
fetch.rs: Parallel fetching pipeline. Spawns scoped threads for slow queries (GPU, packages, IPs, active interface, motherboard, BIOS, displays, audio, WiFi, Bluetooth, UI theme/fonts, camera, gamepad) and collects results intoSystemInfo. ExposesCollectOptionsto decouple collection from the CLI argument parser, making the library usable withoutclap. -
gpu.rs: GPU detection across Linux (/proc,/sys, PCI ID database lookup), macOS (system_profiler), and Windows (WMI/registry). -
display.rs: Display detection and EDID parsing. On Linux, reads/sys/class/drmand raw EDID bytes directly, falling back toxrandr. Parses monitor names, preferred resolutions, refresh rates, and serial numbers from EDID Detailed Timing Descriptor (DTD) blocks. -
network.rs: Network interface detection, IP resolution, and Wi-Fi. Detects the active interface and local IP via/proc/net/route(Linux native) or platform routing commands, fetches the public IP, builds the formatted interface list with per-interface IPv4/IPv6 addresses, and detects the connected Wi-Fi SSID and link parameters viaiw/nmcli(Linux),airport(macOS), ornetsh(Windows). Also exposeslookup_pci_vendorfor shared use by bluetooth detection. -
audio.rs: Audio server and device detection. On Linux, scans the process list for PipeWire/PulseAudio and reads hardware card names from/proc/asoundcodec files. On macOS, queriessystem_profiler SPAudioDataType. On Windows, querieswmic Win32_SoundDevice. -
bluetooth.rs: Bluetooth controller state and connected device detection. On Linux, reads/sys/class/bluetoothsysfs entries, resolves adapter hardware via USB (/usr/share/hwdata/usb.ids) and PCI ID databases, and queries connected devices viabluetoothctl. On macOS, parsessystem_profiler SPBluetoothDataType. On Windows, probes via PowerShellGet-Service/Get-PnpDevice. -
battery.rs: Cross-platform battery statistics — reads/sys/class/power_supply/on Linux, calls native CoreFoundationIOPSCopyPowerSourcesInfoAPIs on macOS, and queries WMI on Windows.