Tyler Clemons

Creating Adium Scripts (iTunes)

by on Aug.30, 2008, under Adium, AppleScript, iTunes, Programming

I use Adium and iTunes frequently. One of the cool things about the OS X environment is the integration between applications. For instance, Adium contacts can be linked to Address Book accounts. One of my personal favorites is the integration of Adium and iTunes. Adium can display details of what is currently playing on iTunes such as the name of the song and the artist. The trick is customizing these messages so that they can be presented as suitable away or status messages.

The best way to learn these concepts is to open up one.  That is just what I did.  I found a script that formatted iTunes data.  I was not satisfied with all of its features so I modified it.  I left credit to the original authors in the modified script.

First, we need to create a file structure.  Create a folder called name.AdiumScripts.  name can be anything you like, just make sure you don’t forget it.  Then right click(CTLR+click), and click ’show package contents.’  Create a folder called Contents.  Inside Contents, create a folder called Resources.  The result:


Enter the contents folder. Click HERE for the info.plist file that will direct Adium where to get your script.  Place it in the contents folder.

The following is how the file looks:

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple Computer//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=”1.0″>
<key>Prefix Only</key>
<key>Requires User Interaction</key>
<string>Message iTunes data</string>

name corresponds to the name of your project from earlier.  Under <key>File</key>, we specify the name of the script file that will be called each time %_name {default_message} is called.  Of course, you can change any of these.  It is also possible to create more callable scripts by copying and pasting. {default_message} will be displayed with the track information or if iTunes is not playing. This is required to run the script.

Now enter the Resources folder.  Create a file called name, or whatever you may have changed name to, with the file extension .scpt. You can either use your favorite text editor or the Script Editor.  This is where we will create our actual script that displays the data.

The following script has the following sample output:

Reading and listening to You Are The Pan
By John Williams
From Hook (Original Motion Picture Soundtrack).

The first line is shows my default action combined with the current song name.  The next lines are the artist, and the album.  If iTunes is not active, whether it is paused or not open, the default action will appear. This output is produced by typing: %_name {Reading}The modified script can be found by clicking HERE.

The code is pretty simple to follow so I won’t go into details here.  It is very simple to add more formatting.  It is just a matter of copying and pasting.  The column names found in iTunes are pretty much the same as they are in AppleScript e.g. to access the genre of a track, just use the variable genre.  Adding more substitutions, that is adding more features like %_name, is as simple as expanding the XML tree and placing the new script files in the same directory.

Like always, if you plan on creating a published add-on, be sure to adhere to any current standards. And that’s it. Just click on name.AdiumScripts to install.

Your files will be installed in Library/Application Support/Adium 2.0/Scripts

:, ,

2 Comments for this entry

  • Emil

    Hey, sorry to write on such an old post, but I was wondering if you know how to make a script that shows the itunes if something is playing and if nothing is playing it shows your custom status? Is that possible?

  • Tyler

    Hey Emil.

    Yes. It’s as follows.

    In the script file, you will notice at line 34:

    tell application “iTunes”
    if player state is playing then

    This tell us if iTunes is playing. We can add more functions for pause and stopped using another set of conditionals:

    else if player state is paused then
    #code here
    end if
    else if player state is stopped then
    #code here
    end if

    It should be easy to fill in your own code at this point. Hope this helps!

Leave a Reply

Looking for something?

Use the form below to search the site: