Set iChat status according to physical location

Apr 15, '04 11:24:00AM

Contributed by: jonbauman

There are plenty of scripts to set your iChat status according to what music you're listening to and whatnot. However, since I have a laptop, I find it more useful to set my iChat status message according to where I am at the time (e.g., work, home, cafe down the street). This helps to let people know if it's an appropriate time to message me or not. After a while, I found that I often forgot to change my status accordingly, and I would be advertising that I was at work when I was in fact home or vice-versa. It occurred to me that it was possible to divine this information based on my network connection, so I wrote a daemon script to update my iChat status automatically.

Here's how the script works. Locations can be distinguished by an IP address prefix (subnet), or wireless SSID (the name displayed in the airport menu). The script first checks to see if there is an active wired connection. If so, the status message is set based on a table of names and subnets that the user of the script must create. If there is no wired connection, but wireless is active, the same table is checked for matching subnets and SSIDs. If none are found, then the SSID itself is used. If the script is successful, the iChat status message will be set to "@locationName" for known wired locations, "802.11@locationName" for known wireless locations, and "802.11@SSID" for unknown wireless connections. To help you know its working, the script uses AppleTalk to say "Changing iChat message status" when there is a change.

There are a number of situations that the status message will not be changed:

Here's how to use the script:

  1. Using Script Editor, edit the list of properties at the beginning.
  2. A location can be defined by the ssid and/or subnet fields, but must define a statusMessage field. The subnet field can be a complete IP address if desired, since the script just does substring matching. Make sure to add any new location properties to the localeTable property, or they won't be found.

  3. Edit other properties
  4. Two simple ones are idleTimeout and changePhrase. Making changePhrase "" is an easy way of shutting the script up. It's also relatively straightforward to change the scripts conventions about "802.11" and "@", but if you don't know what you're doing, it may mess things up.

  5. Save the script as an application, making sure to check "Stay Open"

  6. Optionally, use Drop Script Backgrounder to prevent the script from showing an icon in the dock.

    This is a nice way to remove clutter once you're happy with the way the script works, but you'll have to rerun this utility every time you change the script, so keep it around.

  7. Add the script to your startup items (it's not much use if it's not running all the time)
Last, but not least, the source of the script itself -- download it from macosxhints.com: ichatloc.scpt.zip.

[robg adds: I haven't tested the script, but if you travel with your laptop, it could be quite handy. The source was originally included directly with this hint, but due to its length and formatting challenges due to some long lines, I chose to make it a separate download. Jason Snell of Macworld posted a different version in his Macworld Weblog a while back. I haven't compared the two to see how they differ...]

Comments (17)


Mac OS X Hints
http://hints.macworld.com/article.php?story=2004041213242778