Is there a way I can make a Mac Mini sound an audible alarm when it's not connected to the Internet?

I'm quite handy with bash, so if bash is the answer I could create a couple of commands - one to turn it on, one to turn it off - and create some desktop icons for it.


The following loop will send a single ICMP ECHO request (ping) to your ISP and then sleep for a second. If a reply isn't received within two seconds, it will play the file alarm.wav.

while :
  ping  -t 2 -o -c 1 $YOUR_ISP || open alarm.wav
  sleep 1
  • 4
    for more fun, replace "open alarm.wav" with "say ping failed" – Doug Harris Sep 8 '09 at 19:42
  • will the test continue to run each second? will alarm.wav keep playing? will it re-open the wav every second? will it stop playing once connection has returned? – Phillip B Oldham Sep 9 '09 at 8:14
  • The test will continue. The alarm will play continuously as long as the connection is down and will stop once the connection has returned. – Diomidis Spinellis Sep 19 '09 at 5:35

The following will ping once and tell iTunes to start playing if the ping failed.

ping -c 1 ||
osascript -e 'tell application "iTunes"' -e "play" -e "end tell"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.