App to alert if Internet connection is lost Is there an app for the Mac that will alert me if my Internet connection is lost?

Sometimes I work from home and lose my connection without knowing it.
The following script will alert you when your wireless network no longer has a connection. Though you could modify the script to require a check to locate a specific SSID, the following script simply looks for any wireless network connection. The script can be run via a Launch Daemon (login option preferred) or by simply running the script manually when you decide.


  Alert mechanism: 
  
  If you do not have a wireless network connection the script will set
  your volume to be set at its maximum, you will then hear an alert
  beep and the following phrase "your wireless network has been
  disconnected".


NOTE: This script contains an internal loop. The loop is designed to sleep for 2 min intervals so as not to constantly beep and verbalize said phrase. This interval can be modified to your liking by modifying the "SLEEP_TIMER" variable found within the script.

ALSO: If you are interested in setting up a Launch Daemon but do not have a lot of experience with Daemons, I recommend using Lingon (was once free but Lingon 3 is $2.99).

Tested on:


10.5.x
10.6.x
10.7.4


Please remember to utilize a testing environment prior to running on your primary environment. Feel free to modify the script in any way that suits you, enjoy.

#!/bin/bash

# MONITOR_SSID set as true will keep a loop going (Loop timer 1 minute delay)

MONITOR_SSID="true"

SLEEP_TIMER="60"

while ( ${MONITOR_SSID} == true ); do

    SSID=$(networksetup -getairportnetwork en1 | sed "s:.*\: ::g" | tr -s "[\n]" "[ ]" | sed 's/.*off.*/OFF/g')

    if [[ ${SSID} == "OFF" ]]; then
        osascript -e 'set volume 10'
        afplay -v 2 /System/Library/Sounds/Sosumi.aiff
        say "Wireless network has been disconected"
    elif [[ ${SSID} != "OFF" ]]; then
        :
    else
        /usr/bin/logger -i Error has occured while 'your_script_name' was attempting to run
    fi

    sleep ${SLEEP_TIMER}

done