Get Notification when a specific wifi network becomes available

Ever wanted to be notified when a certain wifi network becomes available?.

Maybe you are at University and the wifi goes up and down randomly. Just like the person I originally wrote this code for who is charged for mobile data when using their iPhone as personal hotspot during the Uni. wifi outage.

Here is a simple way of doing just that.

The code gets the available wifi list. And pops up a notification when the one you want is in the list.
[wce_code id=”2″]
[wce_code id=”3″]


on idle  — A on idle handler will run the code within it and then set the app to idle. Using little cpu. It will then repeat this every #n of seconds ( determined by its return number)

 set theWifi to “weehronetwork” — the wifi SSID 

 set theList to paragraphs of (do shell script “/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s| awk ‘{print $1}'”)   — get the wifi list

    if theList contains theWifi then

      display notification with title “The WIFI” subtitle (theWifi & “  IS BACK UP”) sound name “Sosumi” — display a notification. 

    end if

  return 60  — run again in #n seconds

end idle


Save the Applescript as an Application and check Stay open.

?Screen Shot 2014-09-21 at 01.25.50


When you first run the App. and it displays a Notification, it will then be shown in the System preferences – -> Notifications. From here you can determine the Notification type.

Screen Shot 2014-09-21 at 01.27.22


Screen Shot 2014-09-21 at 01.34.04

 

Notifications using Notification Center are 10.8. X upwards. If you want to use this code on older OS versions use the display dialog command in applescript

 

I have used a sound in this code. But if you uncheck ‘Play Sound for notifications’ in the Notification Center preferences, the sound will not play.