robinadr

Tagged scripts

Update: This has been made obsolete by the much-improved plugin.

Courtesy of Joey Brooks, a.k.a. tunicwriter, here is an AppleScript script for X-Chat Aqua that you can use to show your currently playing iTunes song to the rest of the IRC chatroom. Of course, if iTunes isn’t running, a message is shown to that effect.

I want to make it clear that none of it is my code — all Joey’s. Direct all complaints to him1.

tell application "System Events"
    if exists process "iTunes" then
        tell application "iTunes"
            set theCurrentState to player state
            if theCurrentState is paused then
                "Now Playing: Nothing, iTunes is currently paused."
            else if theCurrentState is stopped then
                "Now Playing: Nothing, iTunes is currently stopped."
            else
                "Now Playing: " & artist of current track & " - " & name of current track & " (Album: " & album of current track & ")"
            end if
        end tell
    else
        "Now Playing: Nothing, iTunes is not open."
    end if
end tell

Here are some brief instructions:

  1. Open up Script Editor (Applications — AppleScript — Script Editor). Paste that code in there, and save it someplace safe.
  2. In X-Chat Aqua, open up the User Commands preference list (X-Chat Aqua — Preference Lists — User Commands…).
  3. Click the “+” button, and change the command name to NP and set the area for text on the right to something like exec -o osascript /Users/yourusername/path/to/xchat/script.scpt. Of course, change the path to where you saved the script file in step 1.
  4. Press Ok, go to a channel window, type /np and press enter. It should output something simliar to Now Playing: Hoobastank - The Reason (Album: The Reason).

Notes

An area where this script could be improved is to use an action (the /me command), which makes a lot more sense. Unfortunately neither Joey or I have been able to find a way to use AppleScript to get X-Chat Aqua to use the /me command, but if you do find a way, please do let me know as I’ve been searching for a while.

And, no, putting “/me” in the command itself doesn’t work. Already tried that. Would be nice if that worked, though.


  1. Sort of kidding…