Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Set iChat status according to physical location' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Set iChat status according to physical location
Authored by: StarManta on Apr 23, '04 01:42:04PM
I modified the script to work with iChatStatus, a freeware PrefPane app. So it's basically the same thing, only a little less trouble to set up if you already have iChatStatus installed. This also has the changes that crashcane pointed out (since they worked for me), if the script does not work, try reversing his change.

property UC : {ssid:"NoWireUC", subnet:"129.137.164", statusMessage:"@UC"}
--insert your locales here, as modeled in the original script... the rest of mine removed for privacy reasons
property localeTable : {UC}
property idleTimeout : 60 -- seconds

on getLocation()
	set wiredIP to do shell script "ifconfig en0 | awk '/inet / {print $2}'"
	set wirelessIP to ""
	set ssid to ""
	set connected to false
	set wired to false
	set IPAddress to ""
	
	if wiredIP is not "" then
		set IPAddress to wiredIP
		set connected to true
		set wired to true
	else
		set wirelessIP to do shell script "ifconfig en1 | awk '/inet / {print $2}'"
		
		if wirelessIP is not "" then
			set IPAddress to wirelessIP
			set ssid to do shell script "system_profiler SPAirPortDataType|awk -F\": \" '/Current Wireless Network/{print $2}'"
			set connected to true
			set wired to false
		end if
	end if
	return {connected:connected, wired:wired, IPAddress:IPAddress, ssid:ssid}
end getLocation

on debug(phrase)
	--say phrase
end debug

on setStatus()
	set currentLocation to my getLocation()
	
	if wired of currentLocation then -- set based on IP
		repeat with locale in localeTable
			try -- locale may not have subnet field
				if IPAddress of currentLocation begins with subnet of locale then
					return my changeStatusTo(statusMessage of locale)
				end if
			end try
		end repeat
	else -- we must have wireless, since connected is true
		
		repeat with locale in localeTable
			try -- locale may not have subnet field
				if IPAddress of currentLocation begins with subnet of locale then
					return my changeStatusTo("802.11" & statusMessage of locale)
				end if
			end try
		end repeat
		
		-- no IP matches, check SSID
		
		if ssid of currentLocation is "" then -- should never happen
			return ("Wireless connection, but no SSID")
		end if
		
		repeat with locale in localeTable
			try -- locale may not have SSID field
				if ssid of currentLocation is ssid of locale then
					return ("802.11" & statusMessage of locale)
				end if
			end try
		end repeat
		
		-- no matches in table, just set to SSID
		return ("802.11@" & ssid of currentLocation)
	end if
	
	
end setStatus


my setStatus()




[ Reply to This | # ]