The code on this post has been updated. View here to get the latest.
In my previous post I talked about what I have been doing to my desktop the last little while. I had quite a few email or IM me asking about how the GeekTool scripts I used. Just take these scripts and copy the lines you want into the command area of a Geeklet. Most of these were written by Mac Newbold. Enjoy!
CPU Usage
top -n1 -l1 | grep "Load Avg" | sed 's/.*usage: //; s/ user.*//;'
top -n1 -l1 | grep "Load Avg" | sed 's/.*user, //; s/ sys.*//;'
top -n1 -l1 | grep "Load Avg" | sed 's/.*sys, //; s/ idle.*//;'
Memory
top -n 1 -l 1 | grep PhysMem | sed 's/.* inactive, //; s/ used.*//;'
top -n 1 -l 1 | grep PhysMem | sed 's/.* used, //; s/ free.*//;'
Month
date +%B
Date
date +%d
Day
date +%A
Time
date +%I:%M
AM / PM
date +%p
Weather
curl --silent "http://xml.weather.yahoo.com/forecastrss?p=USUT0078&u=f" | grep -E '(Current Conditions:|F<BR)' | sed -e 's/Current Conditions://' -e 's/<br \/>//' -e 's/<b>//' -e 's/<\/b>//' -e 's/<BR \/>//' -e 's/<description>//' -e 's/<\/description>//'
Look for the ‘UT0078′ here and replace it with the city code you want to display. Get the city code by going to Yahoo Weather and searching for your city. Once found look in the url and you will see your city code at the end of the url.
Weather Image
Create a new Shell Geeklet and use this as the command:
curl --silent "http://weather.yahoo.com/forecast/USUT0078.html" | grep "forecast-icon" | sed "s/.*background\:url(\'\(.*\)\')\;\ _background.*/\1/" | xargs curl --silent -o /tmp/weather1.png\
Replace the city code with your city code. ( same steps to get city code as above )
Then create a new Image Geeklet and use this as the url:
file:///tmp/weather1.png















I followed your code for the weather image, your code matches a few others, and they are not working…..i’m not sure what I’m doing wrong..
can you help me out?
Thanks
Hayden
Mine stopped working a few days back. The images are hosted by Yahoo. I’m guessing they have moved the image around or something so they are no longer in the same place. I will look into this and if I find an answer I will post it back here.
The code in this post calls the weather images from Yahoo. They recently changed the location of these images so the GeekTool code no longer works. If you take the url at the beginning of your GeekTool script and paste it into a browser it will redirect you to the new url. Take that the one and paste it back into GeekTool and it will be working again.
http://weather.yahoo.com/forecast/USUT0078.html
changes to
http://weather.yahoo.com/united-states/utah/farmington-2402466/
Sorry took so long to get this posted.
@ Luke:
Your comment doesn’t explain where to get the images, just the forecast on a webpage.
@Chris:
The images are pulled dynamically from the code in this post. You don’t have to go and get them anywhere. Let us know if you can’t get it working and we can see what the problem is.
Okay…it isn’t working. :(
I created a new image geeklet and used the provide URL (above). Nothing appeared, even though I already have the Yahoo Weather shell (up and running on my desktop).
Try this –
curl –silent “http://weather.yahoo.com/united-states/utah/farmington-2402466″ | grep “forecast-icon” | sed “s/.*background\:url(\’\(.*\)\’)\;\ _background.*/\1/” | xargs curl –silent -o /tmp/weather1.png\
Looks like they changed the url where they are hosting their images.
@ Chris – You might not be reading the latest on this. There was an update to this post. http://dojo.codegreene.com/2009/updated-geektool-weather-images/
This didn’t work either.
And I went to the update, where I commented on.
@Chris
Not sure what to tell you. This works for me and for others that have used the script. Maybe start completely over in the process with clean windows. Good luck.
Would it help to tell you that I’m using GeekTool 2.1.2, not 3.0?
@Chris
That might be part of the problem. It doesn’t help me to much though since I have never used that version. I started using GeekTool at 3.0
how can i modify the weather script to show C instead of F?
Look for where it says =f at the end of the yahoo weather url. Change the f to a c. Then you will also have to change the F<BR to C<BR
That should do it.
how could you modify this script so that you can see the forecast for the next day as well?
I’m not sure. If I get a chance I will look into it. It shouldn’t be bad though. You just have to grab the info from yahoo and display it like the current weather.
The only slight problem with that is I don’t really understand what the script is doing :)