Article:
  Build an iTunes Remote Control
Subject:   I wrote this, And it doesn't work.
Date:   2005-03-20 15:00:23
From:   ptwobrussell
Response to: I wrote this, And it doesn't work.

Personally, I haven't ever attempted to take this approach. Have you tried putting it inside the double quotes right after "iTunesRemoteControlDaemon"? Give it a shot.


If it doesn't work, you might want to ask if you actually reboot your system enough to merit going through the trouble of auto-starting this.


If you want to proceed, I'd question why you're using AppleScript to simply run a shell script. You don't need this extra layer of scripting. Your shell script doesn't need to run as admin either. It just needs to run as your user account.


The link I posted before that references login hooks on bombich.com should have been a pointer in the right direction. You ultimately want to have this thing start up as a normal daemon process just like lots of the other things that start up, right?


If you just want a double clickable item to run the script for the dock, you can do that by researching some more on Terminal and saving a terminal session as a Term file. In fact, there a long series here on macdevcenter about that.


M.

Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • I wrote this, And it doesn't work.
    2005-03-20 15:49:46  Cool6324 [View]

    I dont re-boot my system enough, but I do have a iBook that I carry, and I sometimes have to boot. But as long as it's running, I have no problem. I also noticed, that apon excuting the script file in terminal, it does freeze which may give the appearence that nothing is happining, but don't be fooled, the script has been executed!! And do not run it again, because that will cause actions to be repeated. Once the script is opened the terminal, the only way I can get ever thing working is to run this sudo chmod 777 /private/tmp/iTunesRemoteControl in terminal. That will do the trick. I have also added some commands(change album), which anyone can do, copy and paste the info in any if the xxx.pl file's.

    #!/usr/bin/perl

    system "echo 'XXXXX' > /tmp/iTunesRemoteControl";
    system "chmod uga+rw /tmp/iTunesRemoteControl";

    print "Content-type: text/vnd.wap.wml\n\n";

    open MENU, "./menu" or die "'menu' not in current dir";
    while (<MENU>) {print "$_";}
    close MENU;


    Define a varible where XXXXX is, and add it to the daemon

    #!/bin/bash
    ##########################################################
    #Matthew Russell -25 Feb 05
    #Usage: prompt$./iTunesRemoteControlDaemon.scr &
    #
    #This simply reads a file and executes an AppleScript that
    #controls iTunes based on its content.
    #
    #kill the daemon with script killRemoteDaemon.scr
    ##########################################################

    ############
    #User Prefs
    ############
    scriptDir="/Library/WebServer/CGI-Executables"
    remoteCommand="/tmp/iTunesRemoteControl"
    delay="1.0"


    #############
    #begin script
    #############
    while [ 1 ]; do

    status=`cat $remoteCommand`

    case $status in
    "getlyrics") osascript $scriptDir/GoogleLyricSearch.scpt;;
    "nextalbum") osascript $scriptDir/PlayNextAlbum.scpt;;
    "open") osascript $scriptDir/open.scpt;;
    "RandomTrack") osascript $scriptDir/RandomTrack.scpt;;
    "Rewind") osascript $scriptDir/Rewind.scpt;;
    "FastForward") osascript $scriptDir/FastForward.scpt;;
    "MuteUnMute") osascript $scriptDir/MuteUnMute.scpt;;
    "PlayPause") osascript $scriptDir/PlayPause.scpt;;
    "VolumeDown") osascript $scriptDir/VolumeDown.scpt;;
    "VolumeUp") osascript $scriptDir/VolumeUp.scpt;;
    esac

    echo "" > $remoteCommand
    sleep $delay

    done


    As you can see I added some, pointing to the corresponding script.

    I added one to open, change album, and even get Lyrics. The same concept can be used in all applications and you can just add to the existing daemon(I'm Guessing).

    So in closing I've learned alot in two days, I think my "wapTunes" is ready to be shown off to my friends, at school.



    • Matthew Russell photo I wrote this, And it doesn't work.
      2005-03-20 16:24:11  Matthew Russell | O'Reilly AuthorO'Reilly Blogger [View]

      Glad you had fun with this. That's what it's all about!

      M.