Feb 23, '06 06:01:00AM • Contributed by: mirrorspock
It will also open shared drives, if they are defined in the script. If it doesn't find an SSID in the list, it will set the location to Automatic. With some extra work, it should be possible to also set the default printer.
set AirportName to do shell script ¬
"system_profiler SPAirPortDataType|awk -F\": \" '/Current Wireless Network/{print $2}'"
tell application "Finder"
activate
end tell
set CurrentLocation to "Automatic"
if AirportName is "Home" then set CurrentLocation to "Home"
if AirportName is "Work1" then set CurrentLocation to "My work"
if AirportName is "Work2" then set CurrentLocation to "Other Office"
say "I think I am at location " & CurrentLocation & ", I will adjust my network settings accordingly"
tell application "System Events"
click menu item CurrentLocation of menu "Location" of menu item "Location" of menu "Apple" of menu bar 1 of process "Finder"
end tell
if AirportName is "Work1" then mount volume "smb://server/share"
if AirportName is "Home" then mount volume "smb://administrator@mycomputer/share"I hope this is of some use to some people; I use it a few times each day in combination with SleepWatcher.
[robg adds: This previous hint does the same thing via a shell script, and this one works via bash and a launchd item.]
