macos-menubar-watch
v0.1.6
Published
Run a shell command and show its output in the macOS menu bar.
Downloads
175
Maintainers
Readme
macos-menubar-watch
Run a shell command on an interval and show its latest output in the macOS menu bar.
This package is designed to ship a precompiled macOS binary, so end users do not need swift installed.
If the command output contains numeric values such as 350, 350M, or 12.5%, the dropdown menu also renders a recent trend chart.
The output supports | grouping for dual-axis plotting: values on the left side of | are plotted on the left Y axis, and values on the right side are plotted on the right Y axis.
Without |, if exactly two numeric values are extracted it is interpreted as A | B; if more than two numeric values are extracted, all of them are plotted on the left Y axis.
Numeric history is persisted under ~/.macos-menubar-watch/ as plain text:
- grouped samples:
unix_timestamp left_values | right_values - examples:
unix_timestamp 111.000000 222.000000 | 333.000000,unix_timestamp | 111.000000 222.000000 - older history files in the previous format are still readable
Long gaps such as app restarts are visually compressed in the chart and marked with dashed gap indicators instead of wasting horizontal space.
Features
- precompiled macOS binary distribution, so users do not need
swiftinstalled - text-only menu bar summary, with extracted numeric values
- multi-series dual-axis charting with
|grouping - persisted numeric history under
~/.macos-menubar-watch/ - scroll-to-zoom and scroll-to-pan chart navigation
- temporary click annotations for screenshots
Copy Chart Imagemenu action to place the current chart snapshot on the clipboard
Usage
npx macos-menubar-watch "date '+%H:%M:%S'"
npx macos-menubar-watch --interval 2 "pmset -g batt | head -1"
npx macos-menubar-watch -n 10 "curl -s https://api.coinbase.com/v2/prices/BTC-USD/spot | sed -E 's/.*\"amount\":\"([0-9.]+)\".*/BTC\/\\1/'"
p=$(pgrep -f 'ZoomCefHelper \(Renderer\)' | tail -1); npx macos-menubar-watch --history-key zoom-cef-renderer-mem-cpu -n 2 "[ $p ] && printf '%s %s\n' \"\$(top -l 1 -pid $p -stats mem 2>/dev/null | sed -n '\$p' | xargs)\" \"\$(ps -p $p -o %cpu= | xargs)\" || echo N/A"Command Output Rules
- no numeric values: only the latest text is shown
A B C | X Y: left axis getsA B C, right axis getsX YA B |: all values are on the left axis| X Y: all values are on the right axis- no
|and exactly two numeric values: interpreted asA | B - no
|and more than two numeric values: all extracted numeric values are plotted on the left axis
Use --history-key when the command string contains unstable values such as PIDs and you want a stable history filename.
Development
npm run build
node ./bin/macos-menubar-watch.js --helpNotes
- macOS only
- Published package should not require
swifton the end-user machine - Maintainers need Xcode or Xcode Command Line Tools to run
npm run build - Recent numeric samples are cached in memory for several hours and restored from
~/.macos-menubar-watch/on launch - Click the menu bar item and choose
Exitto stop it
