June 28th, 2009
Geektool Setup
After reading a Lifehacker article this last week, I discovered and dived into a Mac app called GeekTool. Similar to Rainmeter for the PC, “GeekTool is a PrefPane (System Preferences module) for Panther or Tiger to show system logs, unix commands output, or images (i.e. from the internet) on your desktop (or even in front of all windows).”
I got a few scripts from Nicinabox, a few from IamAwesome, and the rest were either grabbed from other sites or I wrote them myself.
NOTE: A few of these scripts require Lynx - a text-only web browser.
Here’s the current setup:
And here are the details:
Scripts:
FullTime
date “+%l:%M:%S %p”
Day
date “+%d”
Month
date +%B
Day of Week
date +%A
CPU
top -l 1| awk ‘/CPU usage/ {print $8, $9}’
top -l 1| awk ‘/CPU usage/ {print $10, $11}’
top -l 1| awk ‘/CPU usage/ {print $12, $13}’
Memory
top -l 1 | awk ‘/PhysMem/ {print “Used: ” $8 ” \nFree: ” $10}’
Network
myen0=`ifconfig en0 | grep “inet ” | grep -v 127.0.0.1 | awk ‘{print $2}’`
if [ "$myen0" != "" ]
then
echo “Ethernet: $myen0″
else
echo “Ethernet: INACTIVE”
fimyen1=`ifconfig en1 | grep “inet ” | grep -v 127.0.0.1 | awk ‘{print $2}’`
if [ "$myen1" != "" ]
then
echo “Airport: $myen1″
else
echo “Airport: INACTIVE”
fiwip=`curl –silent http://checkip.dyndns.org | awk ‘{print $6}’ | cut -f 1 -d “<”`
echo “External: $wip”
Weather Temp
lynx -dump http://printer.wunderground.com/auto/printer/CA/YOURCITY.html |awk ‘/Temp/{printf $2, “: “; for (i=3; i<=3; i++) printf $i ” ” }’
Weather Conditions
lynx -dump http://printer.wunderground.com/auto/printer/CA/YOURCITY.html|awk ‘/Cond/ && !/Fore/ {for (i=2; i<=10; i++) printf $i ” ” }’
Weather Sunrise
curl http://m.wund.com/US/CA/YOURCITY.html | grep ‘Sunrise’ | sed -e :a -e ’s/<[^>]*>//g;/</N;//ba’ | sed -e ’s/Sunrise/Sunrise: /g’ | sed -e ’s/PST//g’
Weather Sunset
curl http://m.wund.com/US/CA/YOURCITY.html | grep ‘Sunset’ | sed -e :a -e ’s/<[^>]*>//g;/</N;//ba’ | sed -e ’s/Sunset/Sunset: /g’ | sed -e ’s/PST//g’
Weather Forecast
curl –silent “http://xml.weather.yahoo.com/forecastrss?p=YOURZIP&u=f” | grep -e “Forecast:” -A 2 | tail -n 2 | sed -e ’s/<br \/>//’ -e ’s/<BR \/>//’ | sed “s/\(.*\)\.\ \(.*\)/\1\?\2/” | tr “?” “\n” | sed “s/High\:\ \(.*\)\ Low\:\ \(.*\)/\?H\: \1\ L\:\ \2/” | sed “s/\?\(.*\)/\\1/”
PHP Scripts (placed in ~/Sites/)
Weather Image:
<?php
/* Be Sure to replace CITYDATA in $url with your own city from Yahoo */$url=”http://weather.yahoo.com/forecast/YOURCITYCODE.html”;
$ch = curl_init();
$timeout = 0; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);$divStart = “<div class=\”forecast-icon\”";
$strEnd = “‘); _background-image/* */: none;”;
$start = strpos($file_contents, $divStart) + 50;
$end = strpos($file_contents, $strEnd);
$length = $end-$start;$imagepath=substr($file_contents, $start , $length);
$image=imagecreatefrompng($imagepath);imagealphablending($image, true);
imagesavealpha($image, true);
header(’Content-Type: image/png’);
imagepng($image);
?>
Gmail
<?php
$url = ‘https://USERNAME:PASSWORD@mail.google.com/mail/feed/atom’;
$buffer = file_get_contents($url);
$xml = new SimpleXMLElement($buffer);
//print_r($xml);
echo $xml->fullcount . ” unread\n”;foreach($xml->entry as $entry){
echo $entry->title . ” (from: ” . $entry->author->name . “)\n”;
}
?>










