Browse the docs

online

Returns 1 when the Mac has a working network connection and 0 when it doesn't.

Keyboard Maestro: ONLINE

Details #

online() takes no arguments and returns 1 or 0. It reports whether the Mac currently has a usable network path, the same check the network condition uses. It does not contact any server, so a Wi-Fi network with no internet behind it can still read as online.

Parameters #

Takes 0 arguments. {{ online() }}

Examples #

online()
→ 0
online() == 1 ? "connected" : "offline"
→ offline

Gotchas #

  • Calling it with an argument is an error: online() takes 0 arguments, got 1.

  • The first call after Switchboard starts can wait up to half a second for the network monitor's first report.

  • With nothing real to read (a fake system), the answer is 0.