Subscribe to
Posts
Comments
NSLog(); Header Image

iTunes Remote via SSH

I'm about to go into my living room to read a book (see previous post), but I wanted to continue to play my iTunes songs and control them. Then it dawned on me: I've got a lot of shell scripts to do this for me! Tucked away in ~/Documents/Stuff/MiscShellScripts (which I've added to my path) are little apps named nexttrack, resumetrack, prevtrack, pausetrack, and playtrack.

Their content? They range from being quite simple to a bit more complex. I've posted a few below.

My "pause" script is pretty simple:

#!/bin/sh
osascript \
    -e "tell application \"iTunes\"" \
    -e "  pause" \
    -e "end tell"

My "nexttrack" script is a bit more complex:

#!/bin/sh
osascript \
    -e "tell application \"iTunes\"" \
    -e "  next track" \
    -e "  set x to name of current track & \" by \" & artist of current track & \"\"" \
    -e "  if player state is not playing then" \
    -e "    set x to x & \" [\" & player state as string & \"]\"" \
    -e "  end if" \
    -e "  set result to x" \
    -e "end tell"

I'm off, safe in the knowledge that my PowerBook will serve as a fine remote for my desktop from the living room.

9 Responses to "iTunes Remote via SSH"

  1. you could also use remote apple events and write a nice ASS interface for it.

    or just download one of the many apps that do that.

  2. I've always thought Blackhole Media's "Earphoria" was pretty cool:

    http://www.blackholemedia.com/beta/

    Unfortunately, it looks like they may have abandoned the project.

  3. I did something similar. Except all in one parent shell script simply called itunes. Then I got tired of how slow osascript is and off loaded a lot of it to precompiled applescripts that echo their results via a do shell script command.

  4. Yet another way to control iTunes remotely

         I love the net... I was thinking of a way to do this today and voila! Here's the link: iTunes...

  5. I'm on a mailing list and the topic of AppleScript came up. I forget why, but I posted one of my "Terminal AppleScripts" (usig osascript)...

  6. I wonder if there is any similar kind of functionality put into the windows version - obviously I don't have osascript

  7. Here are some AppleScript tricks for your remote iTunes.

  8. I'd use synergy. Download the demo on download.com, it also shows pitures from amazon.com!

  9. There are enough programs that'd do that for you, for example this one. This one doesn't even use remote apple events (although there are programs that do it that way, too). These programs can do much more than your scripts, like playlist switching. And they're more user-friendly too. I don't know why you'd use those scripts.


Trackback URI | Comments RSS

Leave a Reply

Please abide by the comment policy. Valid HTML includes: <blockquote><p>, <em>, <strong>, <ul>, <ol>, and <a href>. Please use the "Quote Me" functionality to quote comments.