-
-
Notifications
You must be signed in to change notification settings - Fork 39
Description
I've been using tiny-dfr as a system monitor on my 2018 MacBook Pro — showing CPU/GPU temps, fan speed, RAM usage, etc. on the touch bar. To do this I added a Command button type that runs a shell command periodically and displays the stdout as text.
How it works:
Config example:
PrimaryLayerKeys = [
{ Command = "/etc/tiny-dfr/cpu-status.sh", Interval = 3, Stretch = 3 },
{ Command = "cat /proc/loadavg | awk '{print $1}'", Interval = 5, Stretch = 2 },
]Command— shell command run via/bin/sh -cInterval— refresh interval in seconds (default 5)- Renders like a Text button, just centered stdout output
- On error or timeout (3s), displays "—"
Implementation is pretty minimal:
- Two new fields on
ButtonConfig(command,interval) - A
ButtonImage::Commandvariant storing the command, interval, cached output, and last-run timestamp - Refresh logic in the main loop similar to the existing time/battery refresh
displays_commandsflag onFunctionLayerlikedisplays_time/displays_battery
Commands run after privilege drop so they execute as nobody — fine for /proc, /sys, sensors, etc. Execution is synchronous with a 3s timeout so a hung command won't freeze the bar permanently.
I have a working implementation on my fork if there's interest. Wanted to check if this is something you'd consider merging before cleaning it up into a proper PR.
Branch: https://github.com/Pilves/tiny-dfr/tree/feature/command-button
This issue was drafted with Claude Code.