
My weather desktop using geektool, weather.com, and wunderground.com.
Open geektool preference pane, new entry, set the drop down to picture, paste the url or a picture, and set the refresh rate to something nice that doesnt get us in trouble, like 1800 (seconds). The weather.com photo/maps are nice because the picture name remains the same as it updates. I made four of these and arranged them swankly.
For the center forecast part, I used a shell command (new entry -> shell). I used wunderground cause i can get a fairly uncluttered html page to parse. Weather.com's page is huge and awful, but they do provide an rss feed that might be more polite to gank data out of. But anyhoo, first I grab the data with lynx:
/sw/bin/lynx -dump http://printer.wunderground.com/cgi-bin/findweather/getForecast?query=ZIPCODE
then pipe it into awk:
awk '/Temp/ || /Wind/ || /Cond/ && !/Fore/ {printf $1 ": "; for (i=2; i<=10; i++) printf $i " " }'
This throws away all the lines except Temperature, Wind, and Conditions (and excludes the 'Forecast and Conditions' line), and prints it all on one line. Another site would need a different awk line, but you get the idea.
Join the two lines above with a pipe (|), paste into geektool as one long line and set the color and font and background and everything and, neat desktop. I put a echo; before the first command to generate a newline, so it was more centered on the background.
To use noaa.gov weather is a bit trickier. go to this page http://weather.noaa.gov/weather/PAccus.html, where instead of PA is your two letter state code. Then select a location from the drop-down list "Current Weather Conditions". This will be the url you want to grab with lynx. And the awk will be:
awk '/Sky/ || / Temp/ || /Wind /' | head -n 3 | awk '{printf $0}'
So there's a Tiger compatible version of GeekTool floating around finally, and I've been playing around with it the past couple days.
I'm still a beginner at shell scripting and the whole gestalt of modern computing, and I've found this not only fun to play with, but also quite educational, especially with regards to those geekiest of tools, bash one-liners.
I've learned a lot from this, for instance that I like awk. It certainly isn't awkward, lol. And take away my propensity for just doing cool crap because I can, and this thing can still be really quite actually real-world useful. It's already replaced half my Dashboard - I find the displayed information simultaneously more noticible and less in the way.
So here's where I'll put my setup, and any other stuff I found that works nice with GeekTool even if it might not maybe be all that actually useful all the time. And of course, links to the work of others.
My Dealy:
Here's what I got on my desktop right now:
I also have separate group that displays the latest satellite weather maps. Sweet.
iCal events: This is actually pretty involved. I published a calender in iCal to my website, then used a php script to grab and format the information i want out of it, then used:
/sw/bin/lynx -dump http://cutup.org/ical.php
to display it. The -dump option just has lynx dump whatevers in the page to the Terminal. I have it set to refresh every 3600 seconds (1 hour). As the newness wears off, and considering how often my iCal changes this may go down significantly. Note the full path to lynx, it seems to need that even though it's in my $PATH.
Processes: There's a few ways to run this. Right now, I like:
ps -cm -U username | awk '/:/ && $5!~/Dashboard/'
c omits the full path of each process, m orders the processes by memory and -U username shows all processes owned by that user. Plain ps only shows processes run through the terminal, ps -A gives me more than I want to see, ps -U was pretty good, I thought. Replacing the m with r orders the processes by CPU usage, I haven't really decided which one I like better.
The awk command /:/ strips out the top line that names the fields - it says only print lines that include a colon. && (and) do not capture lines where field 5 contains the string "Dashboard" (I dunno - it was annoying me for some reason to see them).
I have this refreshing every 10 seconds. What can I say, i like seeing the numbers change.
Bloglines Unread Items While snooping around in the Bloglines API I found a nice url that returns, very simply, the number of unread items in your account. So:
/sw/bin/lynx -dump http://rpc.bloglines.com/update?user=username@address.com&ver=1
gives you a nice little count. I have this set to refresh every 300 seconds (5 minutes).
uptime, memory, and cpu use I managed to fit all this into a one-liner. I was so proud I left it that way, even though I like refreshing my memory and cpu stats every 10 seconds, and uptime doesn't really need to be updated that often. But what the hell, I have a modern laptop computer, well capable of this sort of frippery. I still wonder which is more intensive, having two separate tasks that refresh at different intervals, or one task that doesn't refresh as efficiently as possible. I have no idea where to even start trying to figure that out.
So anyway, I'm running:
uptime | awk '{printf "up : " $3 " " $4 " " $5 " " }'; top -l 1 | awk '/PhysMem/ {printf "RAM : " $8 ", " }' ; top -l 2 | grep 'CPU usage' | awk {print $6, $7=":", $8, $9="user", $10, $11="sys", $12, $13}'
Ooh, exciting, eh? Basically, using printf instead of print makes it so awk doesn't carriage return after it outputs, allowing this all to go on one very spiffy line at the bottom of my screen.
I have uptime piped into awk and discarding everything but field 3. Then there's some slightly strange calls to top to get the CPU and memory stats. Geektool can't deal with interactive proccesses like top, but top allows us to dump snapshots instead, with the -l flag. So top -l 1 outputs 1 snapshot of top. Geektool is cool with that, and then it's a simple matter of piping the output to awk and printing the applicable field, formatted nicely of course since we're using printf.
For CPU use it's a bit trickier. For some reason top -l 1 prints an inaccurate reading. But oddly enough, if you use top -l 2 you get two readings, and the second one is accurate! I found some crazy workaround, and then someone pointed out that I can just use tail. Heh. So with this and the ip stuff that comes next I was able to retire my SystemStats dashboard widget.
Awk is cool. I found it pretty easy to get started with, simple and useful for lots of everyday grepping type stuff. I learned lots of good stuff about it pretty quickly here and here. The more comfortable I get with stuff like this, the more the 1970's era technology of UNIX appeals to the futurist in me.
Local IP I tried to combine this with the external IP but even with awk and printf I was getting a line break so for now they're separate. It goes:
ifconfig | awk '/broadcast/ {print $2}'
which is field 2 from the line containing "broadcast" in ifconfig. I have this refreshing every 120 seconds.
External IP I'm sure there's a better way but here's how I do it. I have a php script on my server that displays the IP adress of whoever hits it. And I have a script in the webserver part of my local machine that calls it. The script looks like this:
if ($ip = @file_get_contents("http://cutup.org/ip.php")) {
$host = gethostbyaddr($ip);
print "$ip $host";
} else {
print "no net connection?";
}
It gets the external IP from my ip printing page and also does a host lookup. So then:
/sw/bin/lynx -dump http://localhost/~username/loc.php
tells me where my computer is. I like how this is web accessible, so if I can access my server remotely I can see where it is :) You never know, it might come in handy some day. I have this set to refresh every 120 seconds as well.
Calendar This one's simple. All it is:
cal
There's some interesting ideas for cal and Geektool I haven't tested yet at macosxhints, but for now this is good for me.
UPDATE: I came up with a nice oneliner to replace the current date with #'s
cal | sed "s/^/ /;s/$/ /;s/ $(date +%d) / $(date +%d | sed 's/./#/g') /"
Weather:
Geektool can display pictures from a url. So the trick is to find .jpgs online that are refreshed every so often and where the name of the file does not change. I found a bunch at weather.com and some more at uswx.com. Right now I have a group, separate from all the other stuff, that has three pictures running:
http://image.weather.com/images/sat/usvis_600x405.jpg
//us visible satellite
http://image.weather.com/images/sat/regions/northeast_sat_720x486.jpg
// northeast infrared satellite
http://www.intellicast.com/WeatherImg/Satellite/world.gif
// world satellite
There's still room for more, but for now this replaces my US Weather dashboard widget nicely. Notice that you call tell from the picture urls that the filename is not likely to change. If there's a date or time in the name of the picture, this wouldn't be so easy.
STUFF I HAD TO FIGURE OUT:
By default, Geek Tool windows are black text. My backgrounds are usually dark, so I have to change the text color to white before I can even see anything there. I wouldn't mention it except that I couldn't figure out whether my command wasn't working or the display was wierd when I got started.
OTHER STUFF THAT MAY BE OF INTEREST:
I picked this up somewhere, it seems to show all the connections on your network
netstat -ab -f inet | grep -i established | sort +4
This one's neat. It shows the IP's of everyone that visited your site:
tail -5000 /var/log/httpd/access_log | grep -v 127.0.0.1 | awk '{print $1}' | uniq
Or even:
tail -5000 /var/log/httpd/access_log | grep -v 127.0.0.1 | awk '{print $1}' | uniq | nslookup -silent | awk '/name = /'
which gives you their hostname. I'm not clear on how to translate this information into a more useful domain name, when I do I imagine I will probably end up using this a lot.
RESOURCES:
macoshints search for "geek tool"