Skip to content

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

Open

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.

Activity

  1. WhatAmISupposedToPutHere commented on Mar 5, 2026

    @WhatAmISupposedToPutHere
    Member

    Wanted to check if this is something you'd consider merging before cleaning it up into a proper PR.

    I am not opposed to displaying of system information on the buttons (see #75), but running a shell command is not the right approach, as it is very inefficient and the constant wakeups aren't great for battery life.

    This issue was drafted with Claude Code.

    The next time, send me the raw prompt instead of using this thing, i can't be bothered to read things one can't be bothered to write.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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