I just reworked my script a little so I only have one now for iTunes thanks to you asking and me wanting to make it simple for people to implement.
Download the attached .zip file. Open it up. Inside are the script and the exported Geeklet. Move the script to wherever you want (remember where!). Next double-click the Geeklet to open it in Geektool.
All you should have to do is edit the Command box with your own path from:
osascript /Users/brian/Documents/Customization/GeekTool/iTunesInfo.scpt
to
osascript /Users/YOU/where/it/is/iTunesInfo.scpt
This script will show the following info:
Song
Artist
Lyrics
*** iTunes does NOT need to be running for this to work. A big plus in my book!
*** Also, when iTunes is not open, NOTHING is showing. Another plus in my book.
set notify to " "
tell application "iTunes"
if player state is playing then
set who to artist of current track as string
set what to name of current track as string
set onwhat to album of current track as string
set trackPaused to ""
set notify to "Track : " & what & trackPaused & "
Artist : " & who & "
Album : " & onwhat
end if
if player state is paused then
set who to artist of current track as string
set what to name of current track as string
set onwhat to album of current track as string
set trackPaused to " (paused)"
set notify to "Track : " & what & trackPaused & "
Artist : " & who & "
Album : " & onwhat
end if
end tell
notify
#!/bin/bash
if [[ -n `ps x | grep "iTunes -psn" | grep -v grep` ]]; then osascript /Users/<location of script>.scpt
else
echo ""
fi
set notify to ""
tell application "iTunes"
if player state is playing then
set tracksleft to index of current track
set trackstotal to count every track in current playlist
set notify to tracksleft & " of " & trackstotal
end if
if player state is paused then
set tracksleft to index of current track
set trackstotal to count every track in current playlist
set notify to tracksleft & " of " & trackstotal
end if
end tell
notify
set notify to ""
tell application "iTunes"
if player state is playing then
set timeVal to player position
set numHours to (timeVal div hours)
set timeVal to timeVal - (numHours * hours)
set numMinutes to (timeVal div minutes)
set numSeconds to timeVal - (numMinutes * minutes)
set timeStr to "" as string
if (numHours > 0) then
if (numHours < 10) then set timeStr to "0"
set timeStr to (timeStr & numHours)
set timeStr to (timeStr & ":")
end if
if (numMinutes < 10) then set timeStr to (timeStr)
set timeStr to (timeStr & numMinutes)
set timeStr to (timeStr & ":")
if (numSeconds < 10) then set timeStr to (timeStr & "0")
set timeStr to (timeStr & numSeconds)
set timetotal to time of current track
if length of timetotal < 5 then
set timetotal to timetotal
end if
set notify to timeStr & "/" & timetotal
end if
if player state is paused then
set timeVal to player position
set numHours to (timeVal div hours)
set timeVal to timeVal - (numHours * hours)
set numMinutes to (timeVal div minutes)
set numSeconds to timeVal - (numMinutes * minutes)
set timeStr to "" as string
if (numHours > 0) then
if (numHours < 10) then set timeStr to "0"
set timeStr to (timeStr & numHours)
set timeStr to (timeStr & ":")
end if
if (numMinutes < 10) then set timeStr to (timeStr)
set timeStr to (timeStr & numMinutes)
set timeStr to (timeStr & ":")
if (numSeconds < 10) then set timeStr to (timeStr & "0")
set timeStr to (timeStr & numSeconds)
set timetotal to time of current track
if length of timetotal < 5 then
set timetotal to timetotal
end if
set notify to timeStr & "/" & timetotal
end if
end tell
notify
--- change the max number of dashes to determine length of the progression bar
set maxNumberOfDashes to 75
tell application "iTunes"
set playerstate to (get player state)
if playerstate = paused then
set trackPaused to " (paused)"
else
set trackPaused to ""
end if
if playerstate = stopped then
return ""
end if
set trackID to the current track
set trackPosition to the player position
set trackLength to the duration of trackID
set theStream to the current stream title as text
end tell
if theStream is not "missing value" then
set totalData to ""
repeat maxNumberOfDashes times
set totalData to "■" & totalData
end repeat
return totalData
end if
set numberOfDashes to (trackPosition / trackLength) * maxNumberOfDashes as integer
set totalData to ""
repeat numberOfDashes times
set totalData to "■" & totalData
end repeat
return totalData
end
property go1 : false
-- check to see if iTunes is running
tell application "System Events"
set the process_flag to (exists process "iTunes")
end tell
if the process_flag then
-- check to see if iTunes is playing
tell application "iTunes"
if player state contains playing then set go1 to true
end tell
if go1 then
-- do what you need to do
tell application "iTunes"
set foo1 to name of current track
set foo4 to foo1
end tell
end if
end if
Is there anyway to implement a script so you could show the blinking ":" of the clock? I know how to program it but not in unix code. Could somebody help me?
thanks a lot!
--- change the max number of dashes to determine length of the progression bar
set maxNumberOfDashes to 75
property go1 : false
-- check to see if iTunes is running
tell application "System Events"
set the process_flag to (exists process "iTunes")
end tell
if the process_flag then
tell application "iTunes"
set playerstate to (get player state)
if playerstate = paused then
set trackPaused to " (paused)"
else
set trackPaused to ""
end if
if playerstate = stopped then
return ""
end if
set trackID to the current track
set trackPosition to the player position
set trackLength to the duration of trackID
set theStream to the current stream title as text
end tell
if theStream is not "missing value" then
set totalData to ""
repeat maxNumberOfDashes times
set totalData to "■" & totalData
end repeat
return totalData
end if
set numberOfDashes to (trackPosition / trackLength) * maxNumberOfDashes as integer
set totalData to ""
repeat numberOfDashes times
set totalData to "■" & totalData
end repeat
return totalData
end if
end
Use apple script and get the system time. Even second the : is on, odd it is off. I don't know enough about AS to tell you how to do it though.
Thanks for posting this.
However the .zip only contains one file iTunesInfo copy.scpt
Any idea where the "geeklet" went? Or am I blind.![]()
set notify to ""
property go : false
--check to see if iTunes is running
tell application "System Events"
set the process_flag to (exists process "iTunes")
end tell
--run if iTunes is running
if the process_flag then
tell application "iTunes"
if player state is playing then
set timeVal to player position
set numHours to (timeVal div hours)
set timeVal to timeVal - (numHours * hours)
set numMinutes to (timeVal div minutes)
set numSeconds to timeVal - (numMinutes * minutes)
set timeStr to "" as string
if (numHours > 0) then
if (numHours < 10) then set timeStr to "0"
set timeStr to (timeStr & numHours)
set timeStr to (timeStr & ":")
end if
if (numMinutes < 10) then set timeStr to (timeStr)
set timeStr to (timeStr & numMinutes)
set timeStr to (timeStr & ":")
if (numSeconds < 10) then set timeStr to (timeStr & "0")
set timeStr to (timeStr & numSeconds)
set timetotal to time of current track
if length of timetotal < 5 then
set timetotal to timetotal
end if
set notify to "| " & timeStr
end if
if player state is paused then
set timeVal to player position
set numHours to (timeVal div hours)
set timeVal to timeVal - (numHours * hours)
set numMinutes to (timeVal div minutes)
set numSeconds to timeVal - (numMinutes * minutes)
set timeStr to "" as string
if (numHours > 0) then
if (numHours < 10) then set timeStr to "0"
set timeStr to (timeStr & numHours)
set timeStr to (timeStr & ":")
end if
if (numMinutes < 10) then set timeStr to (timeStr)
set timeStr to (timeStr & numMinutes)
set timeStr to (timeStr & ":")
if (numSeconds < 10) then set timeStr to (timeStr & "0")
set timeStr to (timeStr & numSeconds)
set timetotal to time of current track
if length of timetotal < 5 then
set timetotal to timetotal
end if
set notify to "| " & timeStr
end if
end tell
notify
end if
Found a better option for highlighting the date in a calendar. I don't use it but thought someone here might want it.
Found a better option for highlighting the date in a calendar. I don't use it but thought someone here might want it.
Hi, I'd say an even better option would be to the color using ANSI color codes now that Geektool supports those![]()
correct, but for those of us who haven't learned how to do that yet...![]()
cal | sed 's/'`date "+%d"`'/^[[33m&^[[0m/'
cal | sed 's/(^|[^0-9])'`date "+%d"`'([^0-9]|$)/^[[33m&^[[0m/'
#!/bin/bash
if [[ -n `ps x | grep "iTunes -psn" | grep -v grep` ]]; then osascript /Users/<location of script>.scpt
else
echo ""
fi
tell application "System Events"
set powerCheck to ((application processes whose (name is equal to "iTunes")) count)
osascript Users/<location of scpt file>.scpt
set notify to ""
property go : false
tell application "System Events"
set the process_flag to (exists process "iTunes")
end tell
if the process_flag then
tell application "iTunes"
if player state is playing then
set who to artist of current track as string
set what to name of current track as string
set onwhat to album of current track as string
set trackPaused to ""
set notify to "Track : " & what & trackPaused & "
Artist : " & who & "
Album : " & onwhat
end if
if player state is paused then
set who to artist of current track as string
set what to name of current track as string
set onwhat to album of current track as string
set trackPaused to " (paused)"
set notify to "Track : " & what & trackPaused & "
Artist : " & who & "
Album : " & onwhat
end if
end tell
end if
notify
set notify to ""
property go : false
tell application "System Events"
set the process_flag to (exists process "iTunes")
end tell
if the process_flag then
tell application "iTunes"
if player state is playing then
set tracksleft to index of current track
set trackstotal to count every track in current playlist
set notify to "" & tracksleft & " of " & trackstotal & ""
end if
if player state is paused then
set tracksleft to index of current track
set trackstotal to count every track in current playlist
set notify to "" & tracksleft & " of " & trackstotal & ""
end if
end tell
notify
end if
set notify to ""
property go : false
tell application "System Events"
set the process_flag to (exists process "iTunes")
end tell
if the process_flag then
tell application "iTunes"
if player state is playing then
set timeVal to player position
set numHours to (timeVal div hours)
set timeVal to timeVal - (numHours * hours)
set numMinutes to (timeVal div minutes)
set numSeconds to timeVal - (numMinutes * minutes)
set timeStr to "" as string
if (numHours > 0) then
if (numHours < 10) then set timeStr to "0"
set timeStr to (timeStr & numHours)
set timeStr to (timeStr & ":")
end if
if (numMinutes < 10) then set timeStr to (timeStr)
set timeStr to (timeStr & numMinutes)
set timeStr to (timeStr & ":")
if (numSeconds < 10) then set timeStr to (timeStr & "0")
set timeStr to (timeStr & numSeconds)
set timetotal to time of current track
if length of timetotal < 5 then
set timetotal to timetotal
end if
set notify to timeStr & "/" & timetotal
end if
if player state is paused then
set timeVal to player position
set numHours to (timeVal div hours)
set timeVal to timeVal - (numHours * hours)
set numMinutes to (timeVal div minutes)
set numSeconds to timeVal - (numMinutes * minutes)
set timeStr to "" as string
if (numHours > 0) then
if (numHours < 10) then set timeStr to "0"
set timeStr to (timeStr & numHours)
set timeStr to (timeStr & ":")
end if
if (numMinutes < 10) then set timeStr to (timeStr)
set timeStr to (timeStr & numMinutes)
set timeStr to (timeStr & ":")
if (numSeconds < 10) then set timeStr to (timeStr & "0")
set timeStr to (timeStr & numSeconds)
set timetotal to time of current track
if length of timetotal < 5 then
set timetotal to timetotal
end if
set notify to timeStr & "/" & timetotal
end if
end tell
notify
end if
--- change the max number of dashes to determine length of the progression bar
set maxNumberOfDashes to 75
property go1 : false
tell application "System Events"
set the process_flag to (exists process "iTunes")
end tell
if the process_flag then
tell application "iTunes"
set playerstate to (get player state)
if playerstate = paused then
set trackPaused to " (paused)"
else
set trackPaused to ""
end if
if playerstate = stopped then
return ""
end if
set trackID to the current track
set trackPosition to the player position
set trackLength to the duration of trackID
set theStream to the current stream title as text
end tell
if theStream is not "missing value" then
set totalData to ""
repeat maxNumberOfDashes times
set totalData to "■" & totalData
end repeat
return totalData
end if
set numberOfDashes to (trackPosition / trackLength) * maxNumberOfDashes as integer
set totalData to ""
repeat numberOfDashes times
set totalData to "■" & totalData
end repeat
return totalData
end if
end
set notify to ""
property go : false
tell application "System Events"
set the process_flag to (exists process "iTunes")
end tell
if the process_flag then
tell application "iTunes"
if player state is playing then
set currrate to round (rating of current track) / 20
set notify to "" & currrate & " stars"
end if
if player state is paused then
set currrate to round (rating of current track) / 20
set notify to "" & currrate & " stars"
end if
end tell
notify
end if
FIXED!
Must have uploaded the wrong .zip. Correct one is up (at least I hope so!).
Thanks for the great tips on this forum. My desktop is simple, but that's what I want.![]()
curl https://www.rz.fh-hannover.de/etech/schoof/meldungen/export/meldungen.xml | grep 'ueberschrift' | sed -e 's/<ueberschrift>//g'
Thanks for the great tips on this forum. My desktop is simple, but that's what I want.![]()
Hi,hi everyone!
first of all thanks for the great scripts!
I want to parse an xml file. what I got by now I took from the weatherscripts, but its not perfect.
This is my xml: https://www.rz.fh-hannover.de/etech/schoof/meldungen/export/meldungen.xml
I want to show every <ueberschrift> (german for headline) to show up bold and below that <zeile1> and <zeile2> (line1 and line2).
And each headline with its two lines should be seperated to the next headline with a blank line.
By now, i use this:
Code:curl https://www.rz.fh-hannover.de/etech/schoof/meldungen/export/meldungen.xml | grep 'ueberschrift' | sed -e 's/<ueberschrift>//g'
to produce this:
![]()
But I want the headline (<ueberschrift> in bold)
Anyone know how to do this?
Thanks in advance!
curl https://www.rz.fh-hannover.de/etech/schoof/meldungen/export/meldungen.xml | grep -E '(ueberschrift|zeile)'
curl https://www.rz.fh-hannover.de/etech/schoof/meldungen/export/meldungen.xml | grep -E '(ueberschrift|zeile)' | sed -E 's/\<zeile/ &/1'
curl https://www.rz.fh-hannover.de/etech/schoof/meldungen/export/meldungen.xml | grep -E '(ueberschrift|zeile)' | sed -E 's/\<zeile/ &/1' | sed -E 's/\<.+>(.+)\<\/.+>/\1/'
check the codes here