Trigger on Internet Interruption?

Is there a way to trigger KM when apps on my Mac can't access the internet?

There are cases where my internet connection is down, but also cases where something in the Mac is preventing access to the internet.

It would be nice to trigger a macro when the computer can no longer reach the internet.

I think it's very unlikely that @peternlewis would add an actual trigger for this circumstance.

You can roll your own by using a Periodic Trigger and pinging Google (for instance) using an Execute a Shell Script action.

Set the period to whatever is needed for your circumstance.

ping -c 5

Capture the output to a variable and test for success.

Type man ping in the for more info on the ping command.

Thanks! That seems like an elegant solution.

1 Like

Actually I did add this to Keyboard Maestro version 10.0.

Unfortunately, because the system method for detecting changes to network connectivity proved entirely unreliable, I removed it.

Generally I'll only add triggers if the system has some sort of event to detect it - I wont add a trigger that requires a periodic test because of the CPU/Battery consequences of such a trigger.

If I find a way of detecting network connectivity/disconnectivity that is event driven and does not require periodic polling, I will likely add the trigger. But currently there is none. And it's pretty hard to see how it could be done, since the lack of connection could occur anywhere upstream.