Sometimes the wifi looks fine but the connection is crawling. Before opening a terminal and typing ping, I just hit a hotkey and Hammerspoon flashes the average latency on screen.

In ~/.hammerspoon/lib/shortcuts.lua:

function pingResult(object, message, seqnum, error)
  if message == "didFinish" then
    avg = tonumber(string.match(object:summary(), '/(%d+.%d+)/'))
    if avg == 0.0 then
      hs.alert.show("No network")
    elseif avg < 200.0 then
      hs.alert.show("Network good (" .. avg .. "ms)")
    elseif avg < 500.0 then
      hs.alert.show("Network poor(" .. avg .. "ms)")
    else
      hs.alert.show("Network bad(" .. avg .. "ms)")
    end
  end
end

hs.hotkey.bind(hs.settings.get('hotkeyCombo'), "p", function()
  hs.network.ping.ping("8.8.8.8", 1, 0.01, 1.0, "any", pingResult)
end)

Now ⌘⌥⌃ + P pops up a one-line verdict — “Network good (24ms)”, “Network poor(310ms)”, or “No network”. No browser, no terminal, no fuss.

Two bits worth knowing —

  • The regex '/(%d+.%d+)/' plucks the average from hs.network.ping’s summary string — that string formats as min/avg/max/stddev.
  • The thresholds (200, 500) are mine — bump them to taste. Anything under 50ms is great, under 200ms is fine for most things, beyond 500ms you’re going to feel it.