26

Simple iTunes Song Meter

Posted in Music by olivierdeen 1085 days ago
DATA=$(osascript -e 'tell application "System Events"
    set myList to (name of every process)
end tell

if myList contains "iTunes" then
    tell application "iTunes"
        if player state is stopped then
            set output to "Stopped"
        else
            set trackname to name of current track
            set artistname to artist of current track
            set albumname to album of current track
            if player state is playing then
                set output to trackname & " | " & artistname & " | " & albumname & "new_line" & "Playing on iTunes | "
            else if player state is paused then
                set output to trackname & " | " & artistname & " | " & albumname & "new_line" & "Paused | "
            end if
        end if
    end tell
else
    set output to "iTunes is not running"
end if')

echo $DATA | awk -F new_line '{print $1}'
echo $DATA | awk -F new_line '{print $2}'

Comments

User Avatar
thatguyagain 1081 days ago
Great glet :D I fiddled with some of the code to change the layout and for once it works!

Many thanks.

Thatguyagain
User Avatar
finchy 1077 days ago
I am having some trouble editing this to display what I want it to. I just want the song name, artist, and the state of itunes (playing/paused/stopped). I tried removing these lines:

set albumname to album of current track

and

| " & albumname & (on both the playing and paused sections)

But when I do that the text completely disappears.
User Avatar
matt 1076 days ago
I think it's because you only removed one quote, so it's unbalanced. Try removing an extra quote before the portion you removed - i.e. remove

" | " & albumname &
User Avatar
finchy 1076 days ago
Thank you a ton man, that worked. I am still new to this, but I tried modifying it a tiny bit more, as I wanted a new line for each set of information - 1 each for TrackName and Artist and iTunes status. So this is what I did:

else if player state is paused then

set output to trackname & "new_line" & artistname & "new_line" & "Paused"

end if

*where "newline" it's actually an underscore between new and line.

I also did that same line of changes for the playing section of lines. Everything comes out exactly as I am trying to do it. Except now when iTunes is Paused it shows the track name and artist, but does not say "Paused." I get both "Stopped" and "iTunes is not running," though. Any ideas?
User Avatar
BigStupidFresh 1065 days ago
I'm sorry to bother everyone with my noob questions but since there is no .GLET where do I enter this script at? Thanks in advance
User Avatar
matt 1064 days ago
In GeekTool, create a new shell geek let by dragging it onto the desktop. Then in the properties window, paste the above code into the Command field.
User Avatar
epochtiberius 1041 days ago
Thanks for this. I'm really new this so I have no idea if this is a noob question or a bit more advanced, but i would like to add a line that would allow this to display the info from an iTunes radio station stream. It displays the name of the stream for the song name which is fine, but brings up "missing value" for artist and album. Is it even possible for a script to extract artist and song info from an iTunes station stream that embeds that info?
User Avatar
Damo 1038 days ago
Looks great and really easy to edit the script thanks.
User Avatar
Wreckie 1008 days ago
Really like the script. I tried to edit it so it only would show name and artist, but whatever I try, I only get disappearing geeklet.. Help please.
User Avatar
alberto2172 989 days ago
Help!

I want it to show each thing in one line.. so i can make the text bigger and it wouldn't take up all the space in my desktop.

I tried putting

"new_line" but didn't work.

Can anyone help me.

also idk if its just me that this is happening. but i would have to open geek tools and click on shell file for it to refresh and start listening to iTunes. ??? is something wrong!!
User Avatar
enochou 815 days ago
I love this geeklet for 2 main reasons

1. It looks clean

2. It is easy to change the coding to suit my personal preference

Thanks so much for this :)

Log in to comment or register here.