DEV Community

Great Work
Great Work

Posted on Originally published at multimeterapp.com

Send a number to your menu bar with a link

This guide first appeared on multimeterapp.com. Multimeter is a Mac menu bar app that turns any number into a live meter.

Open multimeter://set?key=deploys&value=42 and the Sent Value meter with the key deploys shows 42, right away. If it can open a link, it can update a meter. This works in every version of Multimeter.

Add the meter

  1. Choose Add Meter… from any meter’s menu and pick Sent Value.
  2. In Customize This Meter…, give it a key, like deploys. Keys ignore case.
  3. Send it a value with a link (below). Until the first one arrives the meter says it’s waiting for a value.

Parameters

multimeter://set parameters

Parameter What it does
key Which meter. Required. Case doesn’t matter.
value The number. Required. The first number in the text is used, so value=42%25 works.
min, max The range, so gauges and bars fill correctly. Default 0 to 100.
label Text for the meter’s label.
unit Shown after the number, like cups. Use %25 (an encoded %) for a percentage.
formatted Your own text, shown instead of the number. The value still drives colors and alerts.

Multimeter remembers the last value for each key, across restarts. Encode spaces as %20.

Recipes

From Terminal or any shell script. -g keeps Multimeter in the background so your focus doesn’t jump:

Terminal

open -g "multimeter://set?key=coffee&value=3&max=5&label=COFFEE"
Enter fullscreen mode Exit fullscreen mode

A small shell function for your ~/.zshrc:

~/.zshrc

mm() { open -g "multimeter://set?key=$1&value=$2"; }
# mm deploys 42
Enter fullscreen mode Exit fullscreen mode

Count uncommitted files after every commit, from a git hook:

.git/hooks/post-commit (make it executable)

#!/bin/sh
n=$(git status --porcelain | wc -l | tr -d ' ')
open -g "multimeter://set?key=dirty&value=$n&label=DIRTY"
Enter fullscreen mode Exit fullscreen mode

From Shortcuts: add a URL action with your link, then Open URLs. Run it from the menu bar, a keyboard shortcut or an automation.

From a Raycast script command: any bash script can run the same open -g line.

From Python and Node:

Python

import subprocess
subprocess.run(["open", "-g", "multimeter://set?key=queue&value=17&max=100"])
Enter fullscreen mode Exit fullscreen mode

Node or Bun

import { spawnSync } from "node:child_process"
spawnSync("open", ["-g", "multimeter://set?key=queue&value=17&max=100"])
Enter fullscreen mode Exit fullscreen mode

Check it worked

Run the Terminal line above with your key. The meter should change within a second, and its menu should show the new value.

Troubleshooting

What the meter says, why, and what to do

Symptom Cause Fix
The meter says to give it a key The Sent Value meter has no key yet. Set one in Customize This Meter…, the same word you use in key= in the link.
The meter keeps waiting for a value No link with that key has arrived since the meter was set up, or the keys differ. Check the spelling of key= against the meter. Case doesn’t matter, spelling does.
macOS asks which app to open the link with, or nothing happens Multimeter isn’t installed in /Applications or hasn’t been opened yet. Open Multimeter once, then try again.
Spaces in the label show up as plus signs The link encoded spaces as +. Use %20 for spaces.

Next

Top comments (0)