Hammerspoon Spoon that monitors network interface throughput and displays upload/download speed in the macOS menubar.
The Spoon reads byte counters from macOS netstat for a configurable network interface and renders a compact two-line menubar icon: upload speed on top, download speed below.
- Hammerspoon
- macOS with
ifconfigandnetstatavailable (standard on macOS)
Copy or symlink this folder to:
~/.hammerspoon/Spoons/NetSpeed.spoon/
Or distribute it as NetSpeed.spoon.zip; after unzipping, double-click the .spoon bundle to install it with Hammerspoon.
In your Hammerspoon init.lua:
hs.loadSpoon("NetSpeed")
spoon.NetSpeed:start()Configure public properties before calling start():
hs.loadSpoon("NetSpeed")
spoon.NetSpeed.interface = "en0" -- primary interface to monitor
spoon.NetSpeed.fallbackInterface = nil -- optional fallback, e.g. "utun0"
spoon.NetSpeed.updateInterval = 1 -- seconds between updates
spoon.NetSpeed:start()You can also change the primary interface later:
spoon.NetSpeed:setInterface("utun0")Common interface names on macOS include:
en0— usually Wi-Fi or the primary network adapteren1— another physical network adapter on some Macsutun0,utun1, ... — VPN/tunnel interfaces
Run ifconfig -l in Terminal or hs.execute("ifconfig -l") in Hammerspoon Console to list interfaces on your machine.
start()creates a menubar item and schedules a repeating timer.- The Spoon checks whether
interfaceexists; if not, it triesfallbackInterfacewhen configured. - Each update reads byte counters from
netstat, computes bytes per second since the previous update, and refreshes the menubar icon. - If no configured interface is available, the menubar shows
⚠️and resets counters. stop()stops timers and removes the menubar item.
Public API is documented in Hammerspoon docstring format in init.lua and collected in docs.json.
Main methods:
NetSpeed:start()— start periodic network speed monitoring.NetSpeed:stop()— stop timers and remove the menubar item.NetSpeed:setInterface(interface)— set the primary network interface and reset counters.
Public properties:
NetSpeed.interfaceNetSpeed.fallbackInterfaceNetSpeed.updateIntervalNetSpeed.logger
MIT — see https://opensource.org/licenses/MIT.