123

iTunes song meter

Posted in Music by ifuxusux 1215 days ago

Inspired by the CPU meter posted by blair1618, I made a iTunes song duration meter which (obviously) displays the song progress. Enjoy!

Note: You need to change the "/path-to-script/" in the first row of the code which is

myDisk=`osascript /path-to-script/SongMeter.scpt`

to the path you saved the SongMeter.scpt file. Thanks to spamxlive for telling me about that.

Update: I've now changed the code to show the meter only when the song is playing. If you want a fix, search through the comment section.

Note: The song title, artist and album are parts of a different geeklet, the likes of which are around in the Music section.


Geeklet files to download

Comments

User Avatar
spamxlive 1210 days ago
Tried for quite some time, but couldn't get this to work.... here's what i'm running into

- It's using the wrong script in the glet

- Char encoding is an issue (ticks and qoutes) but I dont think that matters

- It's having trouble with the exprs, it doesn't seem to think $a or $myDisk are of the correct type.

Does this one work for anyone?
User Avatar
ifuxusux 1208 days ago
Oh I forgot to say that you need to change the path to the script in the osascript command to where the script is saved. I'll update this.
User Avatar
ifuxusux 1208 days ago
I've updated it. Re-download the .glet file and change its script as told by the updated description.
User Avatar
Padrich 1208 days ago
Hi!

Thank's for the great geeklet!

But I don't like the red bar.. I would like to change the colour of that...

I only found out how to change the sign and the colour of the bars left...

Is it possible to change?

(Sorry for my english.. :P I'm Swiss)
User Avatar
ifuxusux 1194 days ago
In the tenth row of the script, which is

echo "33[1;31m|33[0mc"

The 31 represents red. You can change it to any color you want, and experiment with colors.

30 is black

31 is red

32 is green

33 is yellow

34 is blue

35 is magenta

36 is cyan

37 is white
User Avatar
jcroucher56 1059 days ago
39 is gray
User Avatar
jcroucher56 1058 days ago
39 is gray
User Avatar
busyscott 1207 days ago
Would be nice if you could set it to display the title and artist of song playing! (fromt he picture you posted I assumed that is what it did)
User Avatar
ifuxusux 1205 days ago
You can find other scripts doing exactly that here in the music category so I didn't post them but I can if you want to.
User Avatar
Ekilo77 1197 days ago
I wanted to ask what the coding you used to make it disappear when the song is not playing. Im trying to apply to to another code but I was unable to understand what part of your code did this. I would appreciate if you could explain to me how to create a code in order to have it disappear when the song is not playing.
User Avatar
ifuxusux 1197 days ago
It's in the AppleScript. The script checks if the song is playing and if it's not, it returns "". If it is playing, it returns the percentage of the player position in the song (elapsed/duration*100). The Geektool script then checks if it is "" or not. Anyway, this is the part of the AppleScript that checks if the song is playing:

if player state is playing then

set output to elapsed

else

set output to ""

end if

Of course this is in `tell application "iTunes"`.

Also, if you don't want it to relaunch iTunes every time you close it, include the 

tell application "System Events"

set myList to (name of every process)

end tell

if myList contains "iTunes" then

-- The tell command and other things are here

end if

part.

Hope this helped.
User Avatar
Padrich 1187 days ago
really nice!

thank you!

i love it =)
User Avatar
mangoberry 1186 days ago
sorry, i'm incredibly new at this... i'm still not quite sure what you change the `"/path-to-script/"` to.
User Avatar
mangoberry 1186 days ago
NEVERMIND~ I figured it out! Thank you for the song meter!
User Avatar
mangoberry 1186 days ago
could you make a script that displays the title and artist of the song in the white font that you used in the example? if it's too much trouble then there's no need to bother!
User Avatar
ifuxusux 1181 days ago
There already are many scripts here in the music category but I'll post one anyway. Copy everything in SongMeter.scpt to another script file (e.g. SongInfo.scpt), but change the part "set output to elapsed" to

set who to artist of current track

set what to name of current track

set onwhat to album of current track

set info to (what & "

" & who & " - " & onwhat)

This is what I used.
User Avatar
ifuxusux 1181 days ago
Then create a shell file like "osascript /path-to-script/name-of-script.scpt" with the path to the script file instead of "/path-to-script/" and the name of the script file instead of "name-of-script".
User Avatar
Dequix 1168 days ago
Is there a possibility to adapt this song meter + the song info to another music playback program such as Spotify? I'm using it to iTunes at the moment, but it would be great to have it to Spotify as well.

If someone knows how, please help!

Thanks!
User Avatar
csos95 1061 days ago
yes to make it work with spotify simply open the SongMeter.scpt and where it says:

if myList contains "iTunes" then

tell application "iTunes"

change iTunes to Spotify so it will look like:

if myList contains "Spotify" then

tell application "Spotify"
User Avatar
tomtomhed 1152 days ago
Hey, I'm really new at this and I can't figure out what to put for path-to-script. Any help would be appreciated. Thanks
User Avatar
matt 1149 days ago
Say you put songMeter.scpt in a scripts folder in your Documents folder, you would use

myDisk=`osascript ~/Documents/Scripts/SongMeter.scpt`

'~' is a shortcut to your home (user) folder. Alternatively you could use:

myDisk=`osascript /Users/yourName/Documents/Scripts/SongMeter.scpt`

Which uses the full path from the root of your hard drive.
User Avatar
dakperson 1144 days ago
Hi, I have a question. So I added the AppleScript info to have the applet show the title, artist, etc, but I cannot figure out how to make that happen on the screen. I don't know what I am doing, as I am veeery new to this. How can I get the AppleScript text into code that I can put in the applet? Or what do I do?
User Avatar
ifuxusux 1143 days ago
You don't need another script for titles, artists, etc., just create a Geektool shell scirpt with the code

#!/usr/bin/osascript

tell application "System Events"

if exists process "iTunes" then -- iTunes is open

tell application "iTunes"

if player state is playing then -- iTunes is playing

return (name of current track) & return & (artist of current track) & " - " & (album of current track) -- You can edit here to change the layout

end if

end tell

end if

end tell



At least that's what I used.
User Avatar
Vangard 1092 days ago
Do you know what font you used for the example?

Love this script! Thanks for all of your help.
User Avatar
ifuxusux 1062 days ago
Helvetica Neue Ultralight. It comes with all Macs.
User Avatar
chrisbacani 1084 days ago
HEY. I've been trying all the scripts on the page. I used the Glet file downloaded, used the script provided above with all the commands and stuff. I don't know what I'm doing wrong. Nothings working and I've been trying everything. All that shows up is the override text I put. (Yes I am a noob at this). Can you please give me a full step by step to making it look exactly like the image provided with a script? Because I don't know what to do. = Thanks
User Avatar
wittynametaken 1084 days ago
Is there any way to change the spacing between the bars? I switched up the font on my mac and now they are a little close to each other.

great script!
User Avatar
chrisbacani 1084 days ago
why do i feel like it's just me it's not working for.....
User Avatar
ifuxusux 1062 days ago
Unfortunately, Geektool doesn't let advanced font options such as spacing.
User Avatar
thatguyagain 1059 days ago
you can change the size if the text but that obviously has disadvantages too
User Avatar
Minimax85 1068 days ago
Any way to change the color of the bars located to the left of the highlighted bar? The bars that have already been played. They are black by default. I'd like to have them white. I would greatly appreciate it!
User Avatar
ifuxusux 1062 days ago
Change the font color to white.
User Avatar
i077 1065 days ago
Thanks. This completes the Now Playing Geeklets that I made.
User Avatar
thatguyagain 1062 days ago
Hey,

I was wondering where the code for changing the number of bars was. I was trying to reduce the length without impacting on the height, to make room for more stuff. Also, Is there any way of making the bars stay on screen when the song is paused?

Thanks,

Thatguyagain
User Avatar
jcroucher56 1059 days ago
Each tick mark counts as 5%. There are 20 tick marks. 5% times 20 tick marks gives you 100% (song complete). Therefore, what you want to do is replace every 5 with, say, a 10, if you want 10 tick marks. (10% x 10 tick marks = 100%)
User Avatar
thatguyagain 1059 days ago
Thanks! That helped a lot :P But im still confused as to how i can keep them on screen when my song is paused...

Thanks,

That Guy Again
User Avatar
jcroucher56 1058 days ago
> Is there any way of making the bars stay on screen when the song is paused?

This is what you want to delete:

if [ $myDisk != "" ]

then

myDisk =`expr 100 - $myDisk `
User Avatar
thatguyagain 1055 days ago
thanks :P all working good now :D

thatguyagain
User Avatar
Klutch_bl3ndz 1060 days ago
not working for me
User Avatar
jcroucher56 1059 days ago
If anyone is interested in having a song meter that has the % completed plus the left side of the bar a solid color, here's the code I came up with. Note, if you want to change the " • " back to " | ", just replace them in the code. (should be four of them)

myDisk=`osascript ~/Documents/Scripts/SongMeter.scpt`

if [ $myDisk != "" ]

then

myDisk =`expr 100 - $myDisk `

typeset -i a=5

while [ $a -lt $myDisk ]

do

echo "•\c" & echo "\033[1;34•\033[0m\c"

a=`expr $a + 5`

done

echo "\033[1;34m•\033[0m\c"

while [ $a -lt 100 ]

do

echo "\033[1;39m•\033[0m\c"

a=`expr $a + 5`

done

echo "\n"

unset myDisk

unset a

fi

Should look like this halfway through song

![Example](http://i.imgur.com/dVMfl.png)
User Avatar
jcroucher56 1058 days ago
(disregard post)
User Avatar
olivierdeen 1057 days ago
I can get the bar on but it stays the same the whole time.

How can i fix this?
User Avatar
ifuxusux 959 days ago
Change refresh rate to 5 or another suitable number.
User Avatar
rluhar95 1049 days ago
I'm really new to these kind of things... so here's what I did, and I was wondering if I could get some help? I downloaded the .glet file, and then geektools asked me if I wanted to run the program. I clicked yes, and then went to geek tools, and a new square had opened up with the code in the command box, but the meter hadn't shown up. I also don't know what to do with the .scpt file. I'm really sorry about my novice ability, but it'd be great if someone could help me out! Thanks!
User Avatar
GiùBox 1046 days ago
Solved
User Avatar
heythereheather01 1039 days ago
Everything is working nice with the code, but why is it that when the song changes the song title and artist are not switching over? Can anyone help me please?
User Avatar
adriiadrii 1032 days ago
The meter is working, but the text doesn't show up. Anyone know how to fix this?
User Avatar
thatguyagain 1020 days ago
if you look through the comments others have encountered this and it has been resolved. The text is a seperate glet, which is available around here somewhere.

That guyagain
User Avatar
Austin_tacious 1017 days ago
I've run into a problem where if I restart my mac, this specific geeklet does not appear at all. Can someone assist me with this?
User Avatar
chimpysgotswag 960 days ago
Great Stuff!
User Avatar
PAOZI 958 days ago
hey, I just don't get what do I have to change of the "/path-to-script/", can someone be more specific about what must I do? Im new in this stuff, please :)
User Avatar
Lou18 942 days ago
Hi everybody, first of all I would say that i'm new user of Geektool and so my knowledge is quite limited. Then i'm french and i apologize also of my "bad" English.

So my problem is is : I have a macbook with mac os x lion and I installed geektool and when I have see this good geeklet I immediately wanted to install it. I did everything that is said to do but nothing appears in the square of geeklet, I have change the "/path-to-script" etc.. but nothing works.

Please, I need some help :)
User Avatar
shub22 915 days ago
Please your geeklet is running all the time and wasting a lot of cycles: what did you install and where ? How can I get rid of it or modify ?

Please REPLY URGENT: HOW ca,n I UNINSTALL your geek let and where is it ????

stehub (arobas) hotmail (dot) com
User Avatar
danielaleiva 899 days ago
Hi!! I am from Argentina new in this geek awesome tool. I have added a new shell to my desktop, then i copy the script information myDisk=`osascript /path-to-script/SongMeter.scpt`

I have the SongMeter file in downloads, so i change the command to myDisk=`osascript /Users/daniela/downloads/SongMeter.scpt`

I did that but nothing appears on the screen when i play a song on iTunes, can you help me? I don't know what am i doing wrong.

thank you!! :)
User Avatar
danielaleiva 899 days ago
Got it, I changed the route also in the .glet file, and the bar with the information appear, but only the lines in red and black, I do not see the information about the song and the artist, is there something else I need to change?? Thank you all once again!!
User Avatar
Jwoof 899 days ago
I hate to be contrary haha but I would like to have the bar displaying all the time. What part of the code do I need to edit or remove to get this to show even when a song isn't playing?

Thanks!
User Avatar
ifuxusux 887 days ago
Answered that above.
User Avatar
DeinHeinz 890 days ago
songmeter dsnt work :-(
User Avatar
sixers_star 879 days ago
I've looked through the comments and tried to find my answer and a couple have written about this but I can't figure it out. I downloaded both attachments and opened the .glet. I changed the first line to say myDisk=`osascript /Downloads/SongMeter.scpt` because the other thing I downloaded some script editing program or file is in my downloads file. If that is all you are supposed to do then I did something wrong however I might have missed something. When I open itunes and play something I don't see anything. The refresh rate is 1 second right now as well. Thank you for the upload though i'll keep working on it.
User Avatar
sixers_star 879 days ago
nevermind I got it. Thanks alot this must have been hard work for you.
User Avatar
hworang00 875 days ago
I don't know if anyone has run into this problem, but when I use grey (39) it doesn't work...just shows up as white. Anyone know how to fix this?
User Avatar
edgonz 873 days ago
Any reason why the song name won't come up?

I'm running OS X (10.7.3)

Thanks!
User Avatar
WTWick 859 days ago
Since updating to 10.7.3, the scpt has stopped working. It is now throwing the following error. If you upload the src, I'll be happy to take a look at the code.

3/17/12 8:33:26.110 PM [0x0-0x1a01a].org.tynsoe.geektool3: /bin/sh: line 2: [: !=: unary operator expected

3/17/12 8:33:26.110 PM [0x0-0x1a01a].org.tynsoe.geektool3: script error: A real number can’t go after this identifier. (-2740)

Wick
User Avatar
cooperbd 807 days ago
Has anyone had this issue:

The song duration bar shows up, but no associated text.

Thanks!
User Avatar
Geeklon 793 days ago
Hi,

Thank you for developing this glet.

"If you want a fix, search through the comment section."

I can't fine that section. Can you post please a link.

Thank you!
User Avatar
jbreeeemx 786 days ago
I need some help, please! Nothing will show. I downloaded both, clicked "yes" I want the command to run. I look at my desktop and it doesn't show at all.

I know I'm new, but I usually can figure things out. This I can't considering nothing comes with instructions...

Someone please help me? Thank you!
User Avatar
edgonz 726 days ago
This script has been broken since 10.7.3.

Looks like the author hasn't updated the script either, so don't waste time with this.
User Avatar
c45p31 674 days ago
Looks good.
User Avatar
timo 662 days ago
Very nice!

How do I get the bars to be of equal thickness though?
User Avatar
flbrooklynboy007 523 days ago
I'm having issues running this one, can someone help This is what I have (keep in mind, I'm very new to both Mac & geeklets):

myDisk=`osascript ~/Documents/Scripts/SongMeter.scpt`

typeset -i a=5

while [ $a -lt $myDisk ]

do

echo "|\c"

a=`expr $a + 5`

done

echo "\033[1;31m|\033[0m\c"

while [ $a -lt 100 ]

do

echo "\033[1;30m|\033[0m\c"

a=`expr $a + 5`

done

echo "\n"

unset myDisk

unset a

fi
User Avatar
jbeck 95 days ago
Hey awesome geeklet, any idea how i could change the initial bars from black to another colour, possibly grey?

Log in to comment or register here.