# Phase 8 — System Metrics One `MetricsService` feeds the desktop widget, seven optional bar pills, an optional Control Center card and Settings → System Metrics (`>metrics`). No Nix configuration, packages, keybinds or system services were changed. ## What is available - CPU utilization, hottest supported CPU temperature, average reported frequency, and a bounded 60-sample CPU graph. - GPU selection, utilization, temperature, VRAM used/total, frequency and power where the driver exposes them. - RAM used/total/percentage, calculated from MemTotal minus MemAvailable. - Configurable local storage paths with used/free/total and usage bars. - Upload/download rates, interface selection and automatic physical-interface totals. - Neutral glass desktop widget with configurable monitor, corner and scale. The default is the primary monitor's upper-right; only Music and System Metrics are desktop widgets. Settings → Bar offers `cpu`, `cpuTemperature`, `gpu`, `gpuTemperature`, `ram`, `storage` and `networkThroughput`. Click a pill to open metrics settings. The storage pill displays the first configured path. Settings → Control Center can add `metrics`. Existing bar/Control Center layouts remain intact; modules are not inserted into saved arrays. ## Collection and portability A single Python standard-library streaming process owns the counters, elapsed-time calculations and sensor reads. It reads Linux `/proc` and `/sys` without sudo, writes no hardware state and installs no daemon. Views register with the singleton; the process stops when no metrics view exists. Multiple monitors and multiple bar pills do not add collectors. The desktop counts as a consumer while enabled, including when covered by an application. The default interval is two seconds, configurable from 1–30 seconds. NVIDIA is queried with the installed `nvidia-smi` at most once per five seconds, with a two-second command timeout. AMD uses DRM/hwmon sysfs. Storage updates at most every 15 seconds. These are minimum cadences: a slower configured interval also slows GPU/storage sampling. Sampling uses monotonic time; new/reset network counters cannot produce negative rates, and the first CPU/network sample is unavailable until a delta exists. GPU support depends on the driver: NVIDIA and AMD paths were checked on this machine; AMD units and missing values also have fixture coverage. Intel/other DRM devices are discovered but utilization is unavailable unless the driver exposes the supported sysfs counter. NVIDIA requires `nvidia-smi` on PATH; there is no fallback requiring privileged tracing. No CPU package-power backend is enabled. Missing values display `—`, never invented zero readings. GPU Auto picks the first discovered device (NVIDIA first); an explicitly selected missing GPU stays unavailable. Auto network sums interfaces with a physical sysfs device, excluding loopback and virtual bridges/VPN interfaces to reduce double counting. Select a named virtual interface explicitly to measure it. No traffic is generated. Storage free includes filesystem-reserved blocks; the snapshot separately supplies user-available bytes. Use **local paths only**: a stuck remote mount can block statvfs. Old values are marked stale after the greater of 10 seconds or three sample intervals; stopped/crashed collectors restart while a consumer remains. Permissions, missing hardware and mount failures remain unavailable. The collector follows the documented [Linux proc interfaces](https://docs.kernel.org/filesystems/proc.html) and [AMDGPU monitoring interfaces](https://docs.kernel.org/gpu/amdgpu/thermal.html). Quickshell Process/SplitParser and layer-window APIs reuse the installed 0.3.1 patterns already used by Cava and the Music widget. ## Try it ```sh ./scripts/glassmxrph run # In another terminal: quickshell ipc --path ./quickshell call shell openSettings metrics quickshell ipc --path ./quickshell call metrics status ``` Try a different monitor/corner, disable the desktop widget, and add metrics pills from Settings → Bar. Add System Metrics in Control Center. With every metrics view disabled/closed, IPC reports `running: false`. Preferences merge with existing configurations and preserve unknown settings. ## Validation ```sh ./scripts/validate # Existing Hyprland session, no running instance of this project: python3 tests/metrics_runtime.py ``` Validation covers CPU guest accounting and counter resets, cache-aware RAM, network elapsed time/reset/new-interface handling, NVIDIA unsupported fields, AMD unit conversion, unavailable sources and config preservation/rejection. Live Wayland tests cover both connected outputs, monitor/corner changes, shared bar/settings/Control Center consumers, idle process shutdown/restart, live source changes, unavailable paths/interfaces, persistence and clean QML/DBus logs. Screenshots and logs stay under ignored `.cache/`; no user screenshots are published. Real telemetry is read-only. Foundation and Control Center runtime regressions also passed; the full metrics card was visually inspected using an isolated QML capture. Nix packaging remains deferred as requested. The source runner still requires the existing Python 3 dependency; NVIDIA telemetry additionally benefits from the host's own driver tool. Phase 9 remains compositor effects, animation/performance polish and final error handling. ## Changed files - `README.md` - `dependencies.json` - `docs/architecture.md` - `docs/compatibility.md` - `docs/phase-8.md` - `docs/validation.md` - `quickshell/bar/ModuleLoader.qml` - `quickshell/bar/modules/MetricsModule.qml` - `quickshell/config/defaults.json` - `quickshell/controlcenter/ControlRegistry.qml` - `quickshell/controlcenter/modules/Metrics.qml` - `quickshell/core/ModuleRegistry.qml` - `quickshell/core/SettingsRegistry.qml` - `quickshell/core/ShellState.qml` - `quickshell/helpers/metrics.py` - `quickshell/metrics/MetricGauge.qml` - `quickshell/metrics/MetricsCard.qml` - `quickshell/services/ConfigLogic.js` - `quickshell/services/MetricsService.qml` - `quickshell/services/qmldir` - `quickshell/settings/Settings.qml` - `quickshell/settings/pages/Bar.qml` - `quickshell/settings/pages/Metrics.qml` - `quickshell/shell.qml` - `quickshell/testing/MetricsDriver.qml` - `quickshell/widgets/SystemMetrics.qml` - `scripts/validate` - `tests/config.test.cjs` - `tests/metrics_runtime.py` - `tests/metrics_test.py`