Run iTunes from TerminalA script and some tweaking in
GeekTool is all it takes...
Found this script on macosxhints.com (courtesy
of David Schlosnagle, www.david-s.net ) and have manipulated it a
little (mostly cosmetic stuff, what to show in the status argument and so on,
plus a volume fix).
It's a nice little script by David that make it possible to run iTunes from a Terminal window, which is pretty nice if you spend a lot of your time there... :-) All you have to do to use it is save it, give it the right permissions (755), and make sure it's in your $PATH. The script... (Look out for nasty line breaks!) ################## #!/bin/sh # #################################### # iTunes Command Line Control v1.0 # written by David Schlosnagle # created 2001.11.08 #################################### showHelp () { echo "-----------------------------"; echo "iTunes Command Line Interface"; echo "-----------------------------"; echo "Usage: `basename $0` <option>"; echo; echo "Options:"; echo " status = Shows iTunes' status, current artist and track."; echo " play = Start playing iTunes."; echo " pause = Pause iTunes."; echo " next = Go to the next track."; echo " prev = Go to the previous track."; echo " mute = Mute iTunes' volume."; echo " unmute = Unmute iTunes' volume."; echo " vol up = Increase iTunes' volume by 10%"; echo " vol down = Increase iTunes' volume by 10%"; echo " vol # = Set iTunes' volume to # [0-100]"; echo " stop = Stop iTunes."; echo " quit = Quit iTunes."; echo " playlist "@" = Play iTunes' playlist named @"; echo " shuf = Shuffle current playlist"; echo " nosh = Do not shuffle current playlist"; } if [ $# = 0 ]; then showHelp; fi while [ $# -gt 0 ]; do arg=$1; case $arg in "status" ) state=`osascript -e 'tell application "iTunes" to player state as string'`; # echo "iTunes is currently $state."; if [ $state = "playing" ]; then artist=`osascript -e 'tell application "iTunes" to artist of current track as string'`; track=`osascript -e 'tell application "iTunes" to name of current track as string'`; album=`osascript -e 'tell application "iTunes" to album of current track as string'`; echo "$artist: $track [$album]"; fi break ;; "play" ) echo "Playing iTunes."; osascript -e 'tell application "iTunes" to play'; break ;; "pause" ) echo "Pausing iTunes."; osascript -e 'tell application "iTunes" to pause'; break ;; "next" ) echo "Going to next track." ; osascript -e 'tell application "iTunes" to next track'; break ;; "prev" ) echo "Going to previous track."; osascript -e 'tell application "iTunes" to previous track'; break ;; "mute" ) echo "Muting iTunes volume level."; osascript -e 'tell application "iTunes" to set mute to true'; break ;; "unmute" ) echo "Unmuting iTunes volume level."; osascript -e 'tell application "iTunes" to set mute to false'; break ;; ## old vol arguments # "vol" ) echo "Changing iTunes volume level."; # vol=`osascript -e 'tell application "iTunes" to sound volume as integer'`; # if [ $2 = "up" ]; then # newvol=$(( vol+10 )); # fi # # if [ $2 = "down" ]; then # newvol=$(( vol-10 )); # fi # # if [ $2 -gt 0 ]; then # newvol=$2; # fi # osascript -e "tell application \"iTunes\" to set sound volume to $newvol"; # break ;; ## new vol fix "vol" ) echo "Changing iTunes volume level."; vol=`osascript -e 'tell application "iTunes" to sound volume as integer'`; if [ $2 = "up" ]; then newvol=$(( vol+10 )); osascript -e "tell application \"iTunes\" to set sound volume to $newvol"; break ; fi if [ $2 = "down" ]; then newvol=$(( vol-10 )); osascript -e "tell application \"iTunes\" to set sound volume to $newvol"; break ; fi if [ $2 -gt 0 ]; then newvol=$2; osascript -e "tell application \"iTunes\" to set sound volume to $newvol"; break ; fi break ;; ## end vol fix ## addition playlist of choice "playlist" ) echo "Changing iTunes playlist."; osascript -e 'tell application "iTunes"' -e "set the new_playlist to "$2" as string" -e "play playlist new_playlist" -e "end tell"; break ;; "shuf" ) echo "Shuffle is ON."; osascript -e 'tell application "iTunes" to set shuffle of current playlist to 1'; break ;; "shuf" ) echo "Shuffle is ON."; osascript -e 'tell application "iTunes" to set shuffle of current playlist to 1'; break ;; "nosh" ) echo "Shuffle is OFF."; osascript -e 'tell application "iTunes" to set shuffle of current playlist to 0'; break ;; ## end addition "stop" ) echo "Stopping iTunes."; osascript -e 'tell application "iTunes" to stop'; break ;; "quit" ) echo "Quitting iTunes."; osascript -e 'tell application "iTunes" to quit'; exit 1 ;; "help" | * ) echo "help:"; showHelp; break ;; esac done # To use the file, save it somewhere in your $path. Then 'chmod 755 filename' to make it executable. # Type 'rehash'. Then you can start using it. Personally mine is named 'itunes', so to start playing # I use the command: # itunes play #If you just type "itunes" it will list the options. Currently the options are: # status = Shows iTunes' status, current artist and track. # play = Start playing iTunes. # pause = Pause iTunes. # next = Go to the next track.p # rev = Go to the previous track. # mute = Mute iTunes' volume. # unmute = Unmute iTunes' volume. # vol up = Increase iTunes' volume by 10% # vol down = Increase iTunes' volume by 10% # vol # = Set iTunes' volume to # [0-100] # stop = Stop iTunes. # quit = Quit iTunes. ################## Then I took GeekTool (another wonderful, useful tool!) and made a little floating window to tell me which song I'm listening to... This has been done previously as well, Robert at celsius1414.com among others, made a nice little similar thing. Mine looks like this (in the upper right corner of my screen, in blue): ![]() In GeekTool, make a new "shell" entry and give it the full path to your script and add the "status" flag /Users/larsc/bin/itunes status Pick the font, fontsize and colour of your choice and size it to fit your preferences. You can always add or delete what the window (ie status flag) should show, in your script. VoilĂ ! GeekTool is a free product from Tynsoe, it's been mentioned elsewhere, but can be found here: http://projects.tynsoe.org/en/geektool/ JAW Software has made a Tiger compatible version, which you can find here: http://www.jaw.it/pages/en/x_misc.html Posted: Fr - Februari 3, 2006 at 01:53 em |
Quick Links
Calendar
Categories
Archives
Statistics
Total entries in this blog:
Total entries in this category: Published On: feb 03, 2006 03:37 em |
||||||||||||||