# Monitor A sidebar block that keeps the time, the battery and the machine's load in view, so the window can run without the menu bar: a clock line on top, then CPU, RAM and GPU as thin bars with their figures in fixed columns. ![Monitor](preview.png) ## What you see One block, 105px tall, 16px side padding, 10px text, three rows under a header: - **Header, 22px:** the time `HH:MM:SS` at 13px semibold (`foreground`; the seconds `dim`), the colons blinking once a second; the date `3 Nov` in `dim`; on the right the battery: a 27×14px cell with a 1px `muted` outline and radius 4, the charge as a soft fill (`foreground` at 33%, `done` while charging, `ansi1` at 20% or less on battery), the percentage in 8.5px semibold on top, a 2×5px nub; an 11px bolt before it while plugged in. - **Rows, 18px each:** `CPU`, `RAM`, `GPU` labels 30px wide in `muted`; a 5px bar on `foreground` at 8%, radius 3; then the figures in three fixed columns (32px right-aligned percent, 14px `·`, 30px right-aligned number) in `dim`. - CPU: busy % over one second; the number is the 1-minute load. Bar colour by load per core: `ansi2` under 0.7, `ansi3` under 1, `ansi1` from 1. - RAM: memory pressure % (100 less `kern.memorystatus_level`); the number is GB used (app + wired + compressed, as Activity Monitor counts). Colour by the kernel's pressure level: normal `ansi2`, warning `ansi3`, critical `ansi1`. - GPU: busy % (`Device Utilization %`); the number is GB of unified memory it holds. `ansi2` under 70, `ansi3` under 90, `ansi1` above. - Until the first sample, the figures show `…`. ## How it behaves - Samples every 3 s; redraws every second for the clock only. - Hover: CPU shows busy %, the 1/5/15-minute loads and the core count (performance + efficiency); RAM shows pressure, used of installed, cached and swap; GPU shows busy % and memory held; the battery shows its state (`charging · 1:10`, `3:12 left`, `charged`, `plugged in, held at this level`). - No clicks, no keys, no agent statuses. ## Built from - `mods/monitor/`: `main.js` (a `View`), `mod.json` (`place: "none"`), `bolt.svg`, `side.js` (swaps in a theme's `chrome_*` colours when it has them, so the block reads light on dark bars, as in Borders' Parchment theme; other themes are used as they are). - `exec("sh", ["-c", SCRIPT])`, one command: `iostat -n0 -c 2 -w 1 | tail -1`, `sysctl -n hw.memsize`, `vm_stat`, `pmset -g batt`, `sysctl` for `kern.memorystatus_vm_pressure_level`, `kern.memorystatus_level`, `vm.swapusage`, `hw.ncpu`, `hw.perflevel0/1.logicalcpu`, `vm.loadavg`, and `ioreg -r -d 1 -w 0 -c IOAccelerator` for the GPU. `cx.timer.every(3000)` and `every(1000)`. - Theme colours only: `foreground`, `muted`, `dim`, `done`, `ansi1`-`ansi3` (through `side.js`). ## Watch out - macOS only: on another system the figures stay `…`. - The clock blinks on the 1 s redraw; a native `.loop` animation would redraw the window at 30 fps (about 6% of a core). - RAM's bar is pressure, not used/total: a full-looking memory with low pressure is normal on macOS. - Battery fields come from `pmset`'s `InternalBattery` line; a desktop Mac has none, so the battery is left out. ## Done when - `herdr-app check mods/monitor` passes. - In a layout, the block shows the ticking clock and today's date within a second, and CPU, RAM and GPU figures within 3 s. - On a laptop the battery shows its percentage, and the bolt appears when plugged in. - Hovering each row shows its detail line.