Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'GeekTool - Useful and fun info on the desktop' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
GeekTool - Useful and fun info on the desktop
Authored by: qramsay on Jul 08, '04 04:31:44PM
I really liked the iTunes in the menubar hint, and spiffied up the output a bit, using info from another hint as well. Here is what the output on the menubar looks like, if the artist and title are too long:

Bach - Mass in B Minor, BWV232, XVIII. Cho... | 4:19
or, if it all fits:

The Verve - The Drugs Don't Work | 5:02
The applescript:

on timeString(time)
    set minutes to time div 60
    set myseconds to (time - minutes * 60)
    if myseconds < 10 then
        set myseconds to "0" & myseconds
    end if
    set timeStr to minutes & ":" & myseconds
end timeString

tell application "iTunes"
    if player state is playing or player state is paused then
        set trkName to name of current track
        set trkPos to player position
        set trkTime to duration of current track
        set trkArt to artist of current track

        my timeString(trkTime - trkPos-1)
        set rem to result

        set display to trkArt & " - " & trkName & " | " & rem
    end if
end tell
My applescript is executed using this shell script, which keeps the remaining time displayed, even if the rest of the information is too long:

if ps x | grep iTunes | grep -q -v grep;   then
    export STR="`osascript iTunesName.scpt | iconv -f utf-8 -t ucs-2-internal`"
    LEN=${#STR}
    if [ "$LEN" -gt "53" ]
    then
        TMP=${STR%%|*}
        echo "${TMP:0:42}... |${STR#*|} " #I'd rather not hard-code it
    else
        echo $STR
    fi
fi
(I would welcome any cleaner suggestions, as I was trying to learn bash scripting via writing this script...) Now if only I knew how to get the text to scroll, without sucking up resources. This script is executed with GeekTool every second, and isn't too bad, but scrolling might cross the line.

---
Give a man a program, and frustrate him for a day;
teach a man to program, and frustrate him for the rest of his life.

[ Reply to This | # ]

GeekTool - Useful and fun info on the desktop
Authored by: Frederico on Jul 08, '04 08:59:08PM
I happen to like a fair amount of information displayed; this is a modified version of a script I've been using for awhile with straight AppleScript for use with GeekTool; the original brings up a dialog and option to edit the track when a specified field is empty and requires addressing. As I'm in the process of cataloging and defining 40 years of music, much of it from vinyl, into iTunes, it's quite handy to see a fair amount of info while I'm working (especially when stuck on the phone with a jabbering client). (:

Sample output:
'Slither' by 'Velvet Revolver' on '(single)' |
Rock | (please rate this track) | -2:49 of 4:16 | 
Free from Apple iTunes QT Videos
The script:
(*Display iTunes Info for GeekTool;  ©2004 by Frederico; frederico@mac.com *)
tell application "System Events"
	if exists process "iTunes" then
		tell application "iTunes"
			try	
				set {n, a, al, g, r, c, d, t} to ¬
					{name, artist, album, genre, rating, comment, duration, time} of current track
				set e to player position
				set rT to my doTime(d - e)
				if n is "" then set n to "(unknown name)"
				if a is "" then set a to "(unknown artist)"
				if al is "" then set al to "(unknown album)"
				if g is "" then set g to "(unknown genre)"
				if r is less than 20 then set rs to "(please rate this track)"
				if r is greater than 19 then set rs to "*"
				if r is greater than 39 then set rs to "* *"
				if r is greater than 59 then set rs to "* * *"
				if r is greater than 79 then set rs to "* * * *"
				if r is greater than 99 then set rs to "* * * * *"
				if c is "" then set c to "(no comment)"
				set displayInfo to "'" & n & "'" & " by " & "'" & a & "'" & " on " & "'" & al & "'" & ¬
					" | " & g & " | " & rs & " | " & "-" & rT & " of " & t & " | " & c
				
			on error errMSG number errnum
				log errMSG
				set displayInfo to "(iTunes Player is not playing)  " & "(" & errMSG & ")"
			end try
		end tell
	else
		set displayInfo to "(iTunes Player not running)"
	end if
	return displayInfo
end tell
on doTime(x)
	set m to x div 60
	set s to (x - m * 60)
	if s < 10 then set s to "0" & s
	return m & ":" & s
end doTime
HTH PS: Rob, I hope this isn't formatted too wide; I used AS carriage returns to squeeze it up a bit. -- F

[ Reply to This | # ]