Adium Plugin Scripts

Adium has great support for AppleScripts (or possibly other scripting languages), in that you define a string, and when this string is typed in as a message, the script is run, and the result is sent as the message instead. Thus, it’s possible to write scripts that allow you to type in: %_itunes And a nicely formatted string, with the current iTunes song is sent to the person you are chatting to. This string can even have hyperlinks embedded in it, so if you were serving your iTunes library up, the person could click on it and download/stream it. The same for %_safari/%_camino, this can be set up to send a hyperlink with the current page, including the title. What is not clear from the internet is how to create these. It’s really quite simple. The scripts must live inside a package: under MacOS X packages are just folders with particular extensions. For instance, is a folder, and it appears to the system/user as an application, or a particular type of package. Double-clicking on it will not opent he folder, but (in this case) run the application. AdiumScripts packages (with the extension .AdiumScripts) will install into your Library when you double-click them. So, the format must be as follows:


The ScriptxName.scpt files must be valid AppleScripts, of the format:

on substitute(arg) –do stuff here return value end substitute

Where value is the value you want printed. You should format it with starting and closing html tags, and any html markup you want. If you want the user to be able to send an argument (%command{argument}), then include it as shown. Inside the Info.plist file, you need to have some important information.

 1    <?xml version="1.0" encoding="UTF-8"?>
 2    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
 3    <plist version="1.0">
 4    <dict>
 5        <key>CFBundleDevelopmentRegion</key>
 6        <string>English</string>
 7        <key>CFBundleGetInfoString</key>
 8        <string>Matt's Adium Scripts</string>
 9        <key>CFBundleIdentifier</key>
10        <string>net.schinckel.AppName.scripts</string>
11        <key>CFBundleInfoDictionaryVersion</key>
12        <string>1.0</string>
13        <key>CFBundleName</key>
14        <string>bundleName</string>
15        <key>CFBundlePackageType</key>
16        <string>AdIM</string>
17        <key>Scripts</key>
18        <array>
19            <dict>
20                <key>File</key>
21                <string>Script1Name</string>
22                <key>Keyword</key>
23                <string>/script1</string>
24                <key>Title</key>
25                <string>Menu Item 1</string>
26            </dict>
27            <dict>
28                <key>File</key>
29                <string>Script2Name</string>
30                <key>Keyword</key>
31                <string>%_script2</string>
32                <key>Title</key>
33                <string>Menu Item 2</string>
34            </dict> </array>
35        <key>Set</key>
36        <string>Script Submenu</string>
37    </dict>
38    </plist>

There are some bits of data you’ll need to change: Matt's Adium Scripts should be a descriptive title for your Scripts. com.schinckel.AppName.scripts should be a unique identifier for your scripts. bundleName could be the name of your bundle. Realistically, these can be anything, although I suspect Adium will only allow one version of a script with a particular identifier, or bundle name. The next bits are the impart ones: Script1Name needs to be the name of a script, minus the .scpt extension. /script1 is the keyword that will trigger this script to be called. And Menu Item 1 is what will be written in the Scripts Sub Menu. It’s possible to have multiple calls to the same script, each one just requires a duplicate dictionary entry, with a different Keyword string. For instance, I use /camino and %_camino to mean the same function, without requiring seperate scripts to be called. Finally, the Script Submenu value needs to be replaced by which Script Sub Menu you want the item to be placed under. For instance, there is already one called System Statistics, and iTunes - Now Playing. Using a value that doesn’t appear already causes a new Sub Menu to be created. I’m not sure if there is a ‘rule’ against using /command, as most of the ones I’ve come across all use %_command. I find this too slow to type, and have adapted them accordingly. You will be able to do this also, now that you know how…