February 23rd, 2004

Your Network is now available

Posted in AppleScript by Diggory

I had another DSL outage this afternoon - the Bayswater exchange seems a little temperamental.

Being a total geek I whipped-up this applescript to alert me when the Network was up again. Simple, but effective…

Of course if your net connection goes down and you want to use it you won’t be able to copy and paste from here - so you’d better copy it now :)
The script needs to be saved as an “application” and it should “stay open”. (there are options for both of those in Script Editor’s “Save As…” menu item.)

[edit] - I posted the script on MacOSXHints and after a few comments have tweaked the code to be more friendly to users with Proxies and people who listen to iTunes:

on idle
set secondsToWaitBetweenChecks to 120 — 2 Minutes between checks

set availText to “Your Network Connection is now available.”
set unavailText to “The network is still down.”

set hostToCheck to “www.apple.com”
set checkNetScript to “scutil -r ” & hostToCheck

try
set netStatus to do shell script checkNetScript
if netStatus is “Reachable” then
my announceText(availText)
activate
quit
else
– my announceText(unavailText)
end if
on error
display dialog “Could not check the net status this time.” buttons {”OK”} default button 1 giving up after 5 — seconds
end try
return secondsToWaitBetweenChecks
end idle

to announceText(textToSpeak)
tell application “System Events”

– If iTunes is running dip the Audio.
if (exists process “iTunes”) then
tell application “iTunes”
set oldVolume to sound volume
set sound volume to (sound volume * 0.25)
delay 1
say textToSpeak
delay 1
set sound volume to oldVolume
end tell
else
say textToSpeak
end if

– If the User has Salling Clicker show a funky alert.
if (exists process “SEC Helper”) then
tell application “SEC Helper”
show screen message textToSpeak
end tell
else
display dialog textToSpeak
end if
end tell
end announceText

Announce Network availability source as Applescript Link (requires MacOS X Panther or Script Editor 2)

You can skip to the end and leave a comment. Pinging is currently not allowed. RSS 2.0

One comment

  1. jade says:

    u love me

    December 14th, 2004 at 7:52 pm

Leave a comment