PDA

View Full Version : GeekTool iTunes script


Lucid
2009-10-12, 15:41
Hi, I had a few bash lines in GeekTool that displayed the information of the current song playing in iTunes (using osascript), but I accidentally deleted them in some way. Although I'm a C++/Java programmer, I'm not all too familiar with AppleScript, and so I can't get the line of code working again. I swear it was something like the following, and then just inserting "name," "artist," or "album" in the blank, but I can't get it to work.

osascript -e 'tell application "iTunes" if player state is playing then _____ of current track'

If anybody could shed some light on the situation, it'd be much appreciated.

chucker
2009-10-12, 19:55
osascript -e 'tell application "iTunes" to if player state is playing then get name of current track'

chucker
2009-10-12, 19:57
You were missing a 'to' and a 'get'. The 'get' is probably obvious; the 'to' is easy enough to explain. You can either have a tell block, like so:

tell application "iTunes"
pause
play
end tell

Or, you can have a single command:

tell application "iTunes" to pause

Lucid
2009-10-12, 20:06
Ohhh, I see now. I realized I was missing somewhere where the 'get' is, but I was trying things like output and return, and the 'to' does make sense. Well, at least I gained something out of this. Thanks for the help.