Friday, September 09, 2011

iChat, Growl, and Lion

UPDATE: This script has been improved; the new version is now on github.
UPDATE 2: Growl 1.3 was just released, so I've updated the script to work with 1.3.  If you were using this script and it broke with 1.3, then just download the updated version from the same place.  If you're still using Growl 1.2.2, you'll need to use the old version of this script.  All the rest of the instructions are the same regardless of which version of Growl you're using.

Lion is the latest version of OS X.  iChat is the chat program that's part of OS X.  Growl is a system that lets all sorts of programs post little notification windows on your screen.

For example, if you get a message in iChat while you're in another window, it's nice to have the message pop up on your screen so you can decide whether or not to switch windows to read it.  Or if a buddy logs in, it's nice to know about that (which can be done in iChat with an audio notification), and see who it is without having to check your buddy list.

I used to use Chax for this.  Chax is a pretty good program, but when a new version of OS X comes out, it takes a little while to catch up.  The main reasons I use Chax are:
  1. Accept text chat invitations without being prompted.
  2. Put all my buddies in the same window.
  3. Give me Growl notifications.
Everything but the Growl feature is now built into iChat in Lion.  (The auto-accept is an AppleScript that ships with Lion; you can turn that on in Preferences:Alerts.  The option for "Show all my accounts in one list" is in Preferences:General.)

Chax isn't yet compatible with Lion, so I searched online and found a little AppleScript program to do a bit of what I need.  Using the ideas from that, I expanded it a bit.  Goodbye Chax; I'll miss you!

To use this:
  1. Install Growl, if you don't have it already.
  2. Visit https://github.com/Piquan/iChat-Growl/raw/master/Growl.applescript in your web browser.  (You can use the formatted page instead.)
  3. Open AppleScript Editor (in Applications:Utilities).
  4. Copy and paste the code from the web page into a new script.
  5. Save it to your home directory's Library:Scripts:iChat folder.  (I used the filename "Growl".)  The iChat folder might not exist; you need to create it.  By default, your Library folder is hidden.  (Personally, I solved that by saving to the desktop, and then I ran "open ~/Library/Scripts" in Terminal so that the Scripts window opened in Finder, and dragged my script there.)
  6. In iChat, open the Preferences.
  7. Under Alerts, select the "Message Received" event.
  8. Turn on "Run an AppleScript script:", and select the script you saved earlier.
  9. Repeat the last two steps for each event you're interested in.

Note that the "Message Received in Chat Room" (which is called "addressed message received" in the AppleScript) and "Invitation to Share Buddy's Screen" (a.k.a. "received remote screen sharing invitation") aren't currently enabled, since it looks like there may be a bug in iChat that will cause them to be confused with each other.

If you use the Growl script for chat invitations, you can't also use the Auto-Accept script, since you can only select one script to be run.  Because of this, I've added an auto-accept capability to this Growl script.  By default, it's turned off, but you can turn it on.  Near the top of the program, there's a line that says:

        property autoAccept : {""}

Change this to:

        property autoAccept : {"text"}

Suggestions for improvements are welcome.  Share and enjoy!

(If you expected the source code to be here in my blog, I've moved it.  See https://github.com/Piquan/iChat-Growl/raw/master/Growl.applescript for my latest version.)