Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
There used to be a thread with Geektool scripts. Is this not the equivalent, kind of?

A better fix may be to use a different service. The weather channel has icons too. I used this script:

curl --silent "http://www.weather.com/weather/right-now/ZIPCODE" | grep -E -o 'http://s.imwx.com/v.20120328.084208//img/wxicon/120/.*png' | head -1 | xargs curl -o /tmp/weather.png

Taken from this posthttps://forums.macrumors.com/posts/15540918/

However, you need to make a slight adjustment to the image URL. To find the image url, just have a look at the page source.

Got it after a bit of playing with the url of both the page and the image. This worked for me for my location, should work for anyone else if they just change the ending of the first url to their location:

curl --silent "http://www.weather.com/weather/today/Pembroke+CAXX0354:1:CA" | grep -E -o 'http://s.imwx.com/v.20130819.175643/img/wxicon/120/.*png' | head -1 | xargs curl -o /tmp/weather1.png

Thanks for the help, yojitani.

yeti
 
Got it after a bit of playing with the url of both the page and the image. This worked for me for my location, should work for anyone else if they just change the ending of the first url to their location:

curl --silent "http://www.weather.com/weather/today/Pembroke+CAXX0354:1:CA" | grep -E -o 'http://s.imwx.com/v.20130819.175643/img/wxicon/120/.*png' | head -1 | xargs curl -o /tmp/weather1.png

Thanks for the help, yojitani.

yeti

I have come across a problem with the image URL in these weather.com image retrieval codes. The /v.xxxxxxxx.xxxxxx/ part of the URL keeps changing. So I rewrote it which seems to do the trick....

Code:
curl --silent "http://www.weather.com/weather/today/[ZIPCODE or Weather.com location ID]" | grep -E '/img/wxicon/120/.*png' | head -1 | cut -f 2 -d '"' | xargs curl -o /tmp/weather.png
 
Hi everybody,

my first post here. I have to thank you all for all I have learned with this thread and the previous ones about GeekTool.

I am having some issues with a script. I want it to show my public adress via airport, ethernet, private ip and SSID.

Code:
#!/usr/bin/perl 

$en0_info = `ifconfig en0 | grep "inet" | grep -v 127.0.0.1`; 
$en1_info = `ifconfig en1 | grep "inet" | grep -v 127.0.0.1`; 
$ext_info = `curl --silent http://checkip.dyndns.org | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}'`;
$airport_network = `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | awk -F: '/ SSID: / {print $2}' | sed -e 's/.*SSID: //'`; 
if($ext_info) { 
    $output .= "External: $ext_info"; 
} else {
    $output .= "External: OFFLINE \n";
} 
if($en0_info) { 
    $en0_info =~ /inet (.*) netmask/s; 
    $output .= "Ethernet: $1 \n"; 
} else {
    $output .= "Ethernet: INACTIVE \n";
} 
if($en1_info) { 
    $en1_info =~ /inet (.*) netmask/s; 
    $en1_info = $1; 
    $output .= "Airport: $en1_info \n";
    $output .= "SSID: $airport_network"; 
} else { 
    $output .= "Airport: INACTIVE";
} 
print "$output";


The main problem is that I am behind a private proxy, and it keeps me showing my IP public adress before the proxy. If I go to http://checkip.dyndns.org in my browser it returns me my proxy IP, the way it should be, but for some reason the geetlet doesn't show it. The main reason to use this geeklet was to know when I was behind the proxy and when I wasn't, so for the moment is not very useful...

any help please?

Cheers

P.D.- sorry for my english, I am not anglophone
 
I wish I knew AppleScript, because I want this!

I don't even know how to get the text in the circle..then I don't know how to use that circle for the other scripts..:(

Anybody have some good links on how to figure this stuff out?

Hi sorry for the late reply, I've not been around as I've been travelling for a couple of months. I get back home next week so if this post doesn't help I'll be happy to make a more comprehensive guide then. :)

I will assume from your other post that you figured out the text okay, and you seem to have the battery working. The itunes one also has its own instructions. (Note: I used the 95% and 100% images from the itunes geeklet because in the original they are red and I wasn't a fan, and I'm not a great image manipulator!)

I made copies of the DiskCapacityMeter folder in my chosen geektool directory, each with a copy of the images (this was a bad idea, when I get a second I'll be getting them to refer to a shared directory to save space). The scripts I simply changed the paths to their relevant folders, and changed the core of the script to get the information I wanted.

I'll run through the changes I made here:

For each one I'll post the script changes I made from the DCM.scpt, this is between setting the path name and when you round the number to 5 to get the right image.

CPU Usage/Temp

Code:
set percTotal to 0
	
	repeat 5 times
		
		set percIdle to (do shell script "top -l2 | grep \"CPU usage\" | tail -1 | awk '{sub(/%\\ i/, \"\\ \");print $7}'") as number
		
		set percTotal to percIdle + percTotal
		
	end repeat
	
	set percAv to percTotal / 5
	
	set perc to 100 - percAv

This takes the cpu usage 5 times and averages them, as you get very erratic values otherwise, and it's pretty meaningless.

For the temperature I used this command directly in the geektool pane:

Code:
/Applications/TemperatureMonitor.app/Contents/MacOS/tempmonitor | awk '{sub(/ C/, "ºC");print}'

You'll need to install the app from here. I can't remember the exact install process to get the terminal tools. The rest of the command just appends the degree symbol. You'll have to play around if you want Fahrenheit, I would probably just do the maths in the command line.

Fan Speed

Code:
set fanSpeed to (do shell script "/Applications/smcFanControl.app/Contents/Resources/smc -f | grep \"Actual speed\" | awk '{print $4}'") as integer
	
	if fanSpeed < 2000 then
		
		set fanSpeed to 2000
		
	end if
	
	set fanPerc to (fanSpeed - 2000) / 42

This gets the percentage of fan speed, the minimum on my machine is 2000 rpm, hence the maths. In practice the speed can drop as low as 1960 or so, which is why I set it to 2000 if it's less, otherwise it can't find the image for -5% etc.

The text is simpler, because you can just display the actual number.
Code:
/Applications/smcFanControl.app/Contents/Resources/smc -f | grep "Actual speed" | awk '{print $4}'

I already had smcFanControl installed, but I can't remember if it required any more changes to use the terminal tools.

Memory Usage

Code:
set usedSpace to (do shell script "top -l1 | grep \"PhysMem\" | awk '{sub(/M\\ f/, \"\\ \");print $10}'") as integer
	
	set usedPerc to (1 - (usedSpace / 8191)) * 100

This checks the memory usage twice, as the first reading is always way off, then gets the percentage used. You can modify this to get it to display what you want. Currently it takes the free memory and gets the percentage that way. That assumes active and wired memory are in use, while inactive and used memory are available. If you want to assume used memory as in use (which it technically is, but is still available if needed) then use the value for inactive memory instead. changing the "f" (for free) to an "in" (for inactive) should probably work.

Code:
top -l1 | grep "PhysMem" | awk '{sub(/M\ f/, " ");printf "%3.2f", (8191-$10)/1024;printf "GB"}'

This is the command for the text.

If you need any more help let me know. I didn't proof read this either so if it makes no sense I'll try to clarify. Finally, I'm no expert in geektool or apple script, and this is the first time I've used either, so no judging my possibly questionable methods!

P.S. Your name is hilarious!
 
Last edited:
Does anyone have the iTunes album art step by step? I searched and found the one but I just cant seem to get it to work.
 
can somebody share this script?
 

Attachments

  • sshot.png
    sshot.png
    2.2 MB · Views: 494
Hi sorry for the late reply, I've not been around as I've been travelling for a couple of months. I get back home next week so if this post doesn't help I'll be happy to make a more comprehensive guide then. :)

P.S. Your name is hilarious!

LOL. :D

Thanks for the reply!

I'll give it a go, do some homework and see how it turns out, but please feel free to elaborate when you get a chance. I'll be happy to read a more in-depth guide.
 
Geektool scripts

Morning all,
I am looking for information on the scripting language that geektool uses.
I am want understanding and knowledge so that I can create my own custom scripts. I am not one that likes to be spoon fed, or just copy & paste. So if anyone could point me in the right direction I would appreciate it.
Thanks,
Kyp
 
Today I downloaded an app called Hermes which is a standalone Pandora Radio client (which seems pretty decent, and also can apparently bypass the skip limit somehow which is nice). It seems that no one has written any geektool scripts to display song info, so I wrote up my own.


Code:
on run
  tell application "System Events"
   set num to count (every process whose name is "Hermes")
  end tell
   if num > 0 then
    tell application "Hermes" 
     get playback state
     set stationname to the current station's name
     set titlename to the current song's title
     set artistname to the current song's artist
     set albumname to the current song's album
     set albumart to current song's art
   if playback state is not paused then
     set info to "Streaming: Pandora Radio" & "  --  Station: " & stationname & "  --  Artist: " & artistname & "  --  Title: " & titlename & "  --  Album: " & albumname
   else 
     set info to "Pandora Radio is Paused"
   end if
    end tell
   end if
 return info
end run

If you would prefer the info to be stacked instead of in a straight line, replace line 14 with the following...

Code:
set info to "Streaming: Pandora Radio" & "\n  Station: " & stationname & "\n   Artist: " & artistname & "\n    Title: " & titlename & "\n    Album: " & albumname

Save the file as whatever (I used Hermes.scpt), and in Geektool set as a shell command, and use the following command (change directory as needed)...

Code:
osascript /Users/USER/WHEREVER/Hermes.scpt

Just thought I'd share in case anyone else uses this app.
[screenshot attached]
 

Attachments

  • geektool-pandora-hermes.png
    geektool-pandora-hermes.png
    2.1 MB · Views: 699
&apos

This may have been discussed before, but I have searched, and could not find an answer.

Is there anyway (in GeekTool) to remove/convert the &apos to an actual apostrophe in my rss feed?

Thanks,
Kyp
 
This may have been discussed before, but I have searched, and could not find an answer.

Is there anyway (in GeekTool) to remove/convert the &apos to an actual apostrophe in my rss feed?

Thanks,
Kyp

Using 'sed' to replace should work, something like...

Code:
sed "s/\&apos/'/g"
 
Being that I am a new mac user, and a new GT user, where would I insert the line in this script?
Code:
sed "s/\&apos/'/g"

Code:
#URL="http://www.thetowntalk.com/rssfeeds/topstories.xml"
URL="http://www.thetowntalk.com/rssfeeds/topstories.xml"
maxLength="600"
start="3"
end="9"

curl --silent "$URL" |
sed -e :a -e '$!N;s/\n//;ta' |
sed -e 's/<title>/\
<title>/g' |
sed -e 's/<\/title>/<\/title>\
/g' |
sed -e 's/<description>/\
<description>/g' |
sed -e 's/<\/description>/<\/description>\
/g' |
grep -E '(title>|description>)' |
sed -n "$start,$"'p' |
sed -e 's/<title>//' |
sed -e 's/<\/title>//' |
sed -e 's/<description>/   /' |
sed -e 's/<\/description>//' |
sed -e 's/<!\[CDATA\[//g' |
sed -e 's/\]\]>//g' |
sed -e 's/</</g' |
sed -e 's/>/>/g' |
sed -e 's/<[^>]*>//g' |
cut -c 1-$maxLength |
head -$end |
sed G |
fmt

Thanks,
Kyp
 
Being that I am a new mac user, and a new GT user, where would I insert the line in this script?

Putting it anywhere after the curl part would work really (I just threw it at the end). Though I ran your script and you need to replace &apos; not &apos. You forgot about the semicolon. So here is the code that will work for you...

Code:
URL="http://www.thetowntalk.com/rssfeeds/topstories.xml"
maxLength="600"
start="3"
end="9"

curl --silent "$URL" |
sed -e :a -e '$!N;s/\n//;ta' |
sed -e 's/<title>/\
<title>/g' |
sed -e 's/<\/title>/<\/title>\
/g' |
sed -e 's/<description>/\
<description>/g' |
sed -e 's/<\/description>/<\/description>\
/g' |
grep -E '(title>|description>)' |
sed -n "$start,$"'p' |
sed -e 's/<title>//' |
sed -e 's/<\/title>//' |
sed -e 's/<description>/   /' |
sed -e 's/<\/description>//' |
sed -e 's/<!\[CDATA\[//g' |
sed -e 's/\]\]>//g' |
sed -e 's/</</g' |
sed -e 's/>/>/g' |
sed -e 's/<[^>]*>//g' |
cut -c 1-$maxLength |
head -$end |
sed G |
fmt |
sed "s/\&apos;/'/g"
 
Thanks Tag, that got me fixed up....

Now if someone would tell me where I can learn more about this scripting language so that I can create my own scripts I would appreciate it.

Again, thanks.

Kyp
 
Thanks Tag, that got me fixed up....

Now if someone would tell me where I can learn more about this scripting language so that I can create my own scripts I would appreciate it.

Again, thanks.

Kyp

I saw your post earlier asking about the programming language of geektool. The issue is, geektool works with nearly all programming languages. The one in your script is referred to as "Bash Shell Scripting". This is the most popular one used by geektool. You can also create Apple Scripts like the one I wrote a few posts back and execute the script through Geektool. Basically anything that you can run on the command line, you can run through geektool. So that means you can run simple unix one liners, php, ruby, and many other languages.

So for starting out I'd say Bash Scripting would be your best bet as honestly most of the geektool scripts use that. There are many tutorials and manuals online for Bash scripting, such as this and this and this. (It should be noted I just googled bash scripting guides and these were some of the first).
 
I have come across a problem with the image URL in these weather.com image retrieval codes. The /v.xxxxxxxx.xxxxxx/ part of the URL keeps changing. So I rewrote it which seems to do the trick....

Code:
curl --silent "http://www.weather.com/weather/today/[ZIPCODE or Weather.com location ID]" | grep -E '/img/wxicon/120/.*png' | head -1 | cut -f 2 -d '"' | xargs curl -o /tmp/weather.png

Thanks. I was trying out a widget recently posted on http://www.macosxtips.co.uk/geeklets/ because it has nicer icons! It doesn't work quite the way I want it to and I haven't had time to work it out. I think he's using the yahoo weather rss feed along with some already downloaded icons. Nice idea, but the weather is way off. This, however, is a nice fix! Thanks!
 
I saw your post earlier asking about the programming language of geektool. The issue is, geektool works with nearly all programming languages. The one in your script is referred to as "Bash Shell Scripting". This is the most popular one used by geektool. You can also create Apple Scripts like the one I wrote a few posts back and execute the script through Geektool. Basically anything that you can run on the command line, you can run through geektool. So that means you can run simple unix one liners, php, ruby, and many other languages.

So for starting out I'd say Bash Scripting would be your best bet as honestly most of the geektool scripts use that. There are many tutorials and manuals online for Bash scripting, such as this and this and this. (It should be noted I just googled bash scripting guides and these were some of the first).


Thanks Bro. I will be looking into Bash/Shell scripting.
 
Geektool Battery Indicator

Guys,
I copied a script from the forum for a battery indicator.
The indicator works, but is not accurate to what is displayed in the top bar.
Geektool shows 84% where the top bad displays 89%.

Here is the script I am using, can I make an adjustment to make it display correct?
max_charge=`system_profiler -detailLevel basic SPPowerDataType | grep mAh | grep Capacity | awk '{print $5 }'`
actual_charge=`system_profiler -detailLevel basic SPPowerDataType | grep mAh | grep Remaining | awk '{print $4 }'`

avail=$(echo "scale=2; $actual_charge / $max_charge * 100" | bc)

avail=`echo $avail | cut -d . -f 1`

let count=5

echo "Battery \c"

while [ $count -le $avail ]
do
if [ $count -le 25 ]
then
echo "\033[1;31m|\c" # red
colour='\033[0;31m'

elif [ $count -le 50 ]
then
echo "\033[1;33m|\c" # yellow
colour='\033[0;33m'

elif [ $count -gt 50 ]
then
echo "\033[1;32m|\c" # green
colour='\033[0;32m'
fi

let count=${count}+5
done

#echo "$colour $avail% $actual_charge(mAh) Remains"
echo $colour $avail%
echo "\033[0m"
 
Guys,
I copied a script from the forum for a battery indicator.
The indicator works, but is not accurate to what is displayed in the top bar.
Geektool shows 84% where the top bad displays 89%.

Here is the script I am using, can I make an adjustment to make it display correct?

Basically that script just divides the actual charge of the battery by the maximum charge and then multiplies it by 100 to give you a percentage. That's how the OS does it as well I'd assume. At most you might see a 1% deviation between the menubar and the geektool script depending on how each system rounds, but that code shouldn't be showing a 5% difference. The variables and math also seems right on in the script, so not sure why you are seeing things not matching up.


To test it, I ran this script on my MacBook Pro, and it matched up perfectly most of the time, though for a few moments I noticed it being off by 1%, though like I said, this is a rounding issue. Hopefully someone else can chime in, because that is curious if you are getting a 5% difference with that code.

The only thing I could think of is, are you setting your geeklet to refresh often enough?
 
The refresh rate is set to 60 seconds.
Currently Geektool = 83% while the OS indicator (what ever the top bar is called) is showing 88%.

Thanks for the reply, hope someone else can key in on the subject.

Have a good one!
Kyp
 
Hey guys, I found a Battery meter that actually works for me with a slight mod, however. As I am new to Mac, I do not know how to combine scripts. So as I'm sitting on the recliner with a broke leg, I would like to know if someone could help me out.
The first script works, but is 5% off. The second script also works, but changed the max to 105 and is now accurate. So how could I combine the scripts to have the colored graph, with the correct %.
Thanks

Both scripts are copied and paste from this site, I take no credit for the script, that goes to the original creator....

Script-5% off
Code:
max_charge=`system_profiler -detailLevel basic SPPowerDataType | grep mAh | grep Capacity | awk '{print $5 }'`
actual_charge=`system_profiler -detailLevel basic SPPowerDataType | grep mAh | grep Remaining | awk '{print $4 }'`

avail=$(echo "scale=2; $actual_charge / $max_charge * 100" | bc)

avail=`echo $avail | cut -d . -f 1`

let count=5

echo "Battery \c"

while [ $count -le $avail ]
do
        if [ $count -le 25 ]
        then
                echo "\033[1;31m|\c" # red
                colour='\033[0;31m'

                elif [ $count -le 50 ]
        then
                echo "\033[1;33m|\c" # yellow
                colour='\033[0;33m'

                elif [ $count -gt 50 ]
        then
                echo "\033[1;32m|\c" # green
                colour='\033[0;32m'
        fi

        let count=${count}+5
done

#echo "$colour $avail% $actual_charge(mAh) Remains"
echo $colour $avail%
echo "\033[0m"

Script-2 changed max to 105 and is now accurate
Code:
ioreg -l | awk '$3~/Capacity/{c[$3]=$5}END{OFMT="%.0f%%";max=c["\"MaxCapacity\""];print(max>0?105*c["\"CurrentCapacity\""]/max:"?")}'

Or, could someone spoonfeed me on how to correct the first script.
Thanks,
Kyp
 
Hey guys, I found a Battery meter that actually works for me with a slight mod, however. As I am new to Mac, I do not know how to combine scripts. So as I'm sitting on the recliner with a broke leg, I would like to know if someone could help me out.
The first script works, but is 5% off. The second script also works, but changed the max to 105 and is now accurate. So how could I combine the scripts to have the colored graph, with the correct %.
Thanks

Or, could someone spoonfeed me on how to correct the first script.
Thanks,
Kyp


If you just want to add +5 to the equation in the first script, adding 5 to the overall max charge on line 3 works just the same as it does in the second script...

Code:
max_charge=`system_profiler -detailLevel basic SPPowerDataType | grep mAh | grep Capacity | awk '{print $5 }'`
actual_charge=`system_profiler -detailLevel basic SPPowerDataType | grep mAh | grep Remaining | awk '{print $4 }'`

avail=$(echo "scale=2; $actual_charge / $max_charge * 100 + 5" | bc)

avail=`echo $avail | cut -d . -f 1`

let count=5

echo "Battery \c"

while [ $count -le $avail ]
do
        if [ $count -le 25 ]
        then
                echo "\033[1;31m|\c" # red
                colour='\033[0;31m'

                elif [ $count -le 50 ]
        then
                echo "\033[1;33m|\c" # yellow
                colour='\033[0;33m'

                elif [ $count -gt 50 ]
        then
                echo "\033[1;32m|\c" # green
                colour='\033[0;32m'
        fi

        let count=${count}+5
done

#echo "$colour $avail% $actual_charge(mAh) Remains"
echo $colour $avail%
echo "\033[0m"

I will say though that something still is off, either how your system is reporting your battery status, or maybe even something with the battery itself because it really shouldn't be off by 5 like that from what I can tell. Though if you simply want to just correct for this problem in the script, the above code should work for you.
 
Thanks for the reply. I will fix the script for now.
But you said it may be something wrong with battery or something. Being that this MBA is less than 30 days old, should I have something looked into?

Thanks again,
Kyp
 
Thanks for the reply. I will fix the script for now.
But you said it may be something wrong with battery or something. Being that this MBA is less than 30 days old, should I have something looked into?

Thanks again,
Kyp

Honestly I'm not sure. It's just a plain odd issue. The script simply calls system_profilier and asks for the battery capacity and remaining mAh values, divides them and multiplies it by 100 to give you the percentage remaining. This should be exactly the same information that your menulet gets and computes to display the information on your menubar. That is why I have no idea why you would be getting different values. Maybe the script is calling a cached value somehow, I dont know, but it shouldn't. I honestly don't know why the script is giving you a value that is 5% off.
 
Last edited:
Tag, Could you please share your wallpaper? is very nice. tks
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.