iTunes Script Help

Discussion in 'General Mac Discussion' started by qwerty007, Jan 22, 2004.

  1. qwerty007 macrumors newbie

    Joined:
    Mar 7, 2003
    #1
    I've tracked down the answer to my question on how to get iTunes to keep playing after i've logged out using the fast user meathod. the only problem is i can't ge the scrpit to work fo rthe life of me. could someone please help me get it working.


    For those who love Panther's Fast User Switching but don't like the menulet in the upper-right corner, here's a shell script to do it.
    #!/bin/sh
    if [[ -z $1 ]]; then
    # robg note: Please enter the next two lines as one without
    # any spaces between the "/" and the "R"
    /System/Library/CoreServices/Menu\ Extras/User.menu/Contents/
    Resources/CGSession -suspend
    else
    USERID=`id -u $1`;
    if [[ -z $USERID ]]; then
    exit -1;
    fi;
    # robg note: Please enter the next two lines as one without
    # any spaces between the "/" and the "R"
    /System/Library/CoreServices/Menu\ Extras/User.menu/Contents/
    Resources/CGSession -switchToUserID $USERID
    fi;

    Save the script in your path and make it executable (chmod 755 script_name). If it is called without any arguments, the script will switch to the login window. If called with a user name or id, it will bring up the password dialog and (assuming the correct password is entered) switch to that user.


    #2. If you want iTunes to continue playing:

    sleep 10
    osascript e- 'tell Application "iTunes" to play


    If you want to combine the two, just put one ‘sleep’ line and then combine the two osascript lines.


    so perhaps your final shell script will look like:

    #!/bin/sh
    if [[ -z $1 ]]; then
    # robg note: Please enter the next two lines as one without
    # any spaces between the "/" and the "R"
    /System/Library/CoreServices/Menu\ Extras/User.menu/Contents/\
    Resources/CGSession -suspend
    else
    USERID=`id -u $1`;
    if [[ -z $USERID ]]; then
    exit -1;
    fi;
    # robg note: Please enter the next two lines as one without
    # any spaces between the "/" and the "R"
    /System/Library/CoreServices/Menu\ Extras/User.menu/Contents/\
    Resources/CGSession -switchToUserID $USERID
    fi;
    sleep 10
    osascript -e 'Tell Application "iChat" to log in'
    # Note if you uncomment the following line, iTunes will begin playing
    # everytime you use this script :)
    #osascript -e 'Tell Application "iTunes" to play'




    if someone could make the script so all i have to do is paste in into the script editor and compile it i would be most greatful.
     
  2. qwerty007 thread starter macrumors newbie

    Joined:
    Mar 7, 2003
    #2
    please please please. i know that someone out there understands applescript. you would be doing me the biggest favor if you can help me to get this to work.
     
  3. qwerty007 thread starter macrumors newbie

    Joined:
    Mar 7, 2003

Share This Page