#!/bin/sh
# MAIN LOGIC
# Use an embedded AppleScript to get the iTunes information
if ps x | grep iTunes | grep -v grep | grep -v -q iTunesHelper ;   then
#echo 'in Track' >> ~/Scripts/geektool/trace.txt
 TRACK=$(osascript -e 'tell application "iTunes"
	if player state is playing then
          set trackname to name of current track
          set output to trackname
	end if
  end tell' | iconv -f utf-8 -t ucs-2-internal)
  if [ "$TRACK" != "" ]; then
    echo $TRACK
  fi
fi
