v.0.2 of my new desktop design by usage of GeekTool
During the rainy weekend i spent some time to fiddle around a bit with the “geektool”. After researching a bit about shell programming and reviewing a lot of scripts and examples i wrote for myself. Then after looking for an appropriate wallpaper i put the script collection into work. This is the result for now.
I used a wallpaper which i found on deviantart.com and the following scripts to build my new desktop design…
A Note regarding the iTunes-Script:
Beside the few cpu cycles using GeekTool, shell, curl etc. the iTunes script had to be removed because of eating 10% cpu alone. But anyway, you’ll find it at the bottom of the post.
this is it for now.. #ilovemygeektoolstyleddesktop ;)
I used a wallpaper which i found on deviantart.com and the following scripts to build my new desktop design…
Beside the few cpu cycles using GeekTool, shell, curl etc. the iTunes script had to be removed because of eating 10% cpu alone. But anyway, you’ll find it at the bottom of the post.
#!/bin/sh # displays the current wheather condition and saves an appropriate image # as well as the forecast for tomorrow and the day after TMP_DIR=/tmp/; # the tmp working-directory TMP_FILE=weather.xml; # the name of the .tmp file file=$TMP_DIR/$TMP_FILE; # the tmp file REGION_URI=germany/berlin/berlin-20065565/; # the url for berlin, germany CITY_CODE=GMXX0007; # the region code for berlin, germany # # get the image for the current conditions # curl -s -o $TMP_DIR/weather.html 'http://weather.yahoo.com/'$REGION_URI; curl -s -o $TMP_DIR/weather.png | \ `grep "div\ class=\"forecast-icon\"\ style=\"background:url" | \ $TMP_DIR/weather.html | \ awk -F"'" '{ printf $2 }'` # # get the forecast # curl -s -o $file 'http://xml.weather.yahoo.com/forecastrss?p='$CITY_CODE'&u=c' # # tomorrow # more $file | grep -E -m 1 '(High:)'| \ sed -e 's/<br \/>//' \ -e 's/<b>//' -e 's/< \/b>//' \ -e 's/<br \/>//' -e 's/<br \/>//' \ -e 's/High://g' -e 's/Low:/-/g' # # the day after tomorrow # more $file | grep -E -m 2 '(High:)' | \ sed -e 's/<br \/>//' \ -e 's/</b><b>//' -e 's/< \/b>//' \ -e 's/<br \/>//' \ -e 's/High://g' -e 's/Low:/-/g' | \ tail -r -n 1
#!/bin/sh # displays the cpu usage for user/system/idle TMP_DIR=/tmp ps -arcwwxo "command %cpu ruser" | \ head -11 | \ sed '/top/d' > $TMP_DIR/cpu.temp cat $TMP_DIR/cpu.temp | \ head -11 | \ sed -e "s/COMMAND/Processes/g" -e 's/ \%CPU RUSER//'
Network I/O
#!/bin/sh # displays the current I/O of a specified network adapter # created by chris helming. # chris dot helming at gmail # get the current number of bytes in and bytes out myvar1=`netstat -ib | grep -e "en0" -m 1 | awk '{print $7}'` # bytes in myvar3=`netstat -ib | grep -e "en0" -m 1 | awk '{print $10}'` # bytes out # wait one second sleep 1 # get the number of bytes in and out one second later myvar2=`netstat -ib | grep -e "en0" -m 1 | awk '{print $7}'` # bytes in again myvar4=`netstat -ib | grep -e "en0" -m 1 | awk '{print $10}'` # bytes out again # find the difference between bytes in and out during that one second subin=$(($myvar2 - $myvar1)) subout=$(($myvar4 - $myvar3)) # convert bytes to kilobytes kbin=`echo "scale=2; $subin/1024;" | bc` kbout=`echo "scale=2; $subout/1024;" | bc` # print the results echo "Network I/O" echo "D: $kbin Kb/sec" echo "U: $kbout Kb/sec"
#!/bin/sh # displays the current RAM usage top -FR -l 1 | awk '/PhysMem/ {print "Used: " $8 " Free: " $10}'
HDD Usage
#!/bin/sh # displays the space of specified hdd's (internal, external Time-Machine Backup) df -h | grep disk0s2 | awk '{print "HDD #1: " $4 " (" $5 " used)"}' # internal df -h | grep "Time" | awk '{print "HDD #2: " $4 " (" $5 " used)"}' # external
#!/bin/sh # displays the 10 most cpu greedy processes TMP_DIR=/tmp ps -arcwwxo "command %cpu ruser" | head -11 | sed '/top/d' > $TMP_DIR/cpu.temp more $GT_DIR/cpu.temp | \ head -11 | \ sed -e "s/COMMAND/Processes/g" \ -e 's/ \%CPU RUSER//'
#!/bin/sh # displays the 10 most memory greedy processes top -orsize -FR -l1 | \ grep % | \ grep -v Load | \ grep -v COMMAND | \ cut -c 7-19,64-69 | \ head -10
#!/bin/sh # displays the calendar of the current month cal
#!/bin/sh # Thanks to Dave Taylor at www.askdavetaylor.com for # the great tutorial on accessing and parsing RSS feeds with a shell script # displays the unread emails from #inbox username='' # username is your email address with @ replaced by %40. password='' # your password url="https://$username:$password@mail.google.com/mail/feed/atom/inbox" if [ $# -eq 1 ] ; then headarg=$(( $1 * 2 )) else headarg="-8" # default is four email messages fi curl -s $url | grep -E '(title>|summary>)' | \ sed -n '2,$p' | \ sed -e 's/<title>//' -e 's/< \/title>//' \ -e 's/<summary>/ /' -e 's/< \/summary>//' | \ head $headarg | \ fmt -w $width
this is it for now.. #ilovemygeektoolstyleddesktop ;)
Schick ! :)
Thanks a lot for line this all out for people. This particular post has been extremely useful to me.
Hi,
I am trying to use your Weather code but I get this message:
In the tmp dir, the script create the .html and .xml weather file.
Can you help me with this.
Tks
it looks like there is a backslash missing in your
sed..should be: