Files
mesh-catalog/modules/power/files/bin/power-draw
T
jochen f2ab795926 Let the bar render blocks other modules contribute, and give it the battery and power draw from the power module (hq ADR 0255)
The bar left the battery out because it belongs to whoever knows the hardware, and had
no way to take it back in. i3status-rust now renders bar-neutral blocks through its
template; the power module contributes the battery where the machine reports one and
the power draw where something measures it, sampling the root-only energy counter as
root and publishing only a rate. The memory block shows what programs hold, the figure
memory-pressure judges by, instead of counting the cache as used.
2026-10-08 14:33:43 +02:00

13 lines
533 B
Bash
Executable File

#!/bin/sh
# power-draw (module power, novox/hq ADR 0255): the power the machine draws, for the bar's block.
#
# Prints the line the module's sampler (`power draw`, as root) publishes every five seconds, which says
# what it measured: "machine" on battery, "CPU" or "CPU+GPU" otherwise. A line older than thirty
# seconds is a sampler that stopped, and is not shown as if it were now.
f=/run/mesh-power/draw
if [ -r "$f" ] && [ $(( $(date +%s) - $(stat -c %Y "$f") )) -le 30 ]; then
head -n 1 "$f"
else
echo "power not measured"
fi