A New Desktop Design

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.

[SinglePic not found]
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.

Weather

#!/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

CPU Usage

#!/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"

RAM Usage

#!/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

Processes

#!/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//'

Memory Hogs

#!/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

Calendar

#!/bin/sh
 
# displays the calendar of the current month
 
cal

Google Mail Unread

#!/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 ;)

This entry was posted in experiments and tagged , , , . Bookmark the permalink.

6 Responses to A New Desktop Design

  1. Delois Bovee says:

    Thanks a lot for line this all out for people. This particular post has been extremely useful to me.

  2. Hi,

    I am trying to use your Weather code but I get this message:

    RodrigoRocha.:.Pretorian] ~  ./teste.sh
    ./teste.sh: line 24: /Users/RodrigoRocha/tmp//weather.html: Permission denied
    curl: no URL specified!
    curl: try 'curl --help' or 'curl --manual' for more information
    Thu - Scattered Thunderstorms.  31 - 23
    sed: 1: "s///
    ": bad flag in substitute command: '/'
    
    And here it's my modifications:
    
    TMP_DIR=/Users/RodrigoRocha/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=brazil/amazonas/manaus-455833/?unit=c;  # the url for Manaus,AM,BR
    
    CITY_CODE=BRXX0146;     # the region code for Manaus,AM,Brasil
    
    My tmp dir permissions
    drwxrwxrwx   4 RodrigoRocha  staff   136 17 Nov 22:07 tmp
    

    In the tmp dir, the script create the .html and .xml weather file.

    Can you help me with this.
    Tks

    • David Linse says:

      it looks like there is a backslash missing in your sed ..

      "s/</b><b>//"

      should be:

      "s/</b><b>//"
    • Tarek says:

      FYI I’m running somhneitg like this:


      $ for locale in $(locale -a); do \
      LC_ALL=$locale sort ./foo.txt > $locale.txt; \
      done;
      $ md5sum *.txt > sums
      $ md5sum *.txt | awk {print $1}' | sort | uniq -c

      Which will show the number of different results, then you can grep the sums file for which locales sort in which order(s).

      • David Linse says:

        What is this useful for ?
        It looks like `md5sum` is a *nix only command as it does not work on OSX 10.6.x (?)

Leave a Reply to Rodrigo Rocha Cancel reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">