A script to toggle between AIM screen names in iChat

Feb 02, '04 10:55:00AM

Contributed by: macubergeek

As many people do, I have two different AIM screen names. While iChat allows you to add additional .Mac account names, it dosn't appear to have a way to allow you to toggle between two different AIM screen names.

So I wrote this script to allow you to do so. It basically rewrites a file named com.apple.iChat.AIM.plist in your ~/Library -> Preferences directory, swapping out the screen names. I'd suggest backing up this file before running this script by doing:

% cd $HOME/Library/Preferences
% cp com.apple.iChat.AIM.plist com.apple.iChat.AIM.plist.backup
Here's the script; beware of line wraps in two of the lines within the case statements -- be sure they are stretched out on one line in your copy.

#!/bin/sh

if [ $# -ne 1 ]; then
  echo 1>&2 "usage: aim second_name or first_name"
  exit 127
fi

aimfile=$HOME/Library/Preferences/com.apple.iChat.AIM.plist

case $1 in
  # remove the line break before $aimfile in each of the
  # first_name and second_name lines below
  first_name) cat $aimfile | sed 's/second_name/first_name/g' > 
    $aimfile.bak && mv $aimfile.bak $aimfile;echo "first_name now active";;
  second_name) cat $aimfile | sed 's/first_name/second_name/g' > 
    $aimfile.bak && mv $aimfile.bak $aimfile;
  echo "second_name now active";;
esac
[robg adds: I haven't tested this, as I have only one iChat ID. But you should be able to just save the script, make it executable, and then run it whenever you wish to swap your AIM name. I think you'll need to quit iChat first before running the script, though.]

Comments (3)


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