Skip to content

Feature request: Command button type for displaying shell command output #82

@Pilves

Description

@Pilves

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 -c
  • Interval — 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::Command variant storing the command, interval, cached output, and last-run timestamp
  • Refresh logic in the main loop similar to the existing time/battery refresh
  • displays_commands flag on FunctionLayer like displays_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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions