16

Another iTunes info geeklet

Posted in Music by thcousins 3017 days ago

DESCRIPTION: A two part geeklet to display the current iTunes song information.

SCREENSHOT:

NOTES:

  1. Layout in the format:

    << [Last song] | [Artist] [Curent song] | [Artist] | [Album] [Playing status] | [Playlist name]-[Playlist source]  >> [Next song] | [Artist]

  2. Written in embedded AppleScript, so should be fairly easy to play around with if you don't like the layout.

CODE:

Now

#---iTUNES | LOCAL CURRENT TRACK---

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
            set track_playlist to name of current playlist
            set track_source to (get name of container of container of current track)
            if player state is playing then
                set output to trackname & "    | " & artistname & " | " & albumname & "new_line" & "Playing | " & track_playlist & "-" & track_source
            else if player state is paused then
                set output to trackname & "    | " & artistname & " | " & albumname & "new_line" & "Paused | " & track_playlist & "-" & track_source
            end if
        end if
    end tell
else
    set output to "iTunes not running"
end if')

echo $DATA | awk -F new_line '{print $1}'
echo $DATA | awk -F new_line '{print $2}'</pre><p>**Last and next**</p><pre>#---iTUNES | LOCAL LAST & NEXT TRACK---

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 ""
        else if shuffle of current playlist is true then
            set output to "<< (shuffle) new_line" & ">> (shuffle)"
        else
            set X to (index of current track)
            set Y to (index of last track) of current playlist
            if X = Y then
                set LAST_TRACK to name of track (X - 1) of current playlist
                set LAST_ARTIST to artist of track (X - 1) of current playlist
                set output to "<< " & LAST_TRACK & " | " & LAST_ARTIST & "new_line >> None"
            else if X - 1 = 0 then
                set NEXT_TRACK to name of track (X + 1) of current playlist
                set NEXT_ARTIST to artist of track (X + 1) of current playlist
                set output to "<< None new_line" & ">> " & NEXT_TRACK & " | " & NEXT_ARTIST
            else
                set LAST_TRACK to name of track (X - 1) of current playlist
                set LAST_ARTIST to artist of track (X - 1) of current playlist
                set NEXT_TRACK to name of track (X + 1) of current playlist
                set NEXT_ARTIST to artist of track (X + 1) of current playlist
                set output to "<< " & LAST_TRACK & " | " & LAST_ARTIST & "new_line" & ">> " & NEXT_TRACK & " | " & NEXT_ARTIST
            end if
        end if
    end tell
end if')

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

UPDATES:

2011/04/22 - corrected the wrong direction '<<' when showing 'none'; added playlist source.

Comments

User Avatar
danhodson 2922 days ago
Is there a way to truncate names as a long song title, long artist name, and long album name leads to a really long list.

Log in to comment or register here.