Total Pageviews

Saturday, 23 February 2013

GeekTool - For Everything Else...

So it's been some time since I last posted. Much has happened since then, some big life changing events but all good thankfully! My life has settled down a little bit now so have found myself with some free time.

I thought then it would good to start posting on blogger again; about something new and not media centre related. Although, plenty of that to come as OpenElec and XBMC has been making big waves since last year.

Over the Christmas period just past I was able to get myself a shiny new Macbook Pro Retina while out in the states. Amazing machine. I'll save you all the usual amount of "it just works", but really it just does. After getting back I immediately set about customising and getting it to a place I was happy with everything.

However, one thing I was lacking was easy ways of getting to information on the system without having to run up several apps. If I wanted to get my IP, I could either use the terminal or the network preferences, if I wanted to check out the system log I could use console or the terminal, if I wanted to check when CCC (Carbon Copy Cloner) last ran a backup, i'd either run up console or the terminal.... you get the picture.

So it seemed I could do everything with the terminal, but having to type in commands time and time again would eventually frustrate me. I want the information now. And as much as I love the terminal, it drives me nuts sometimes.

To solve this challenge, I used a tool called GeekTool. GeekTool allows you to create simple desktop widgets that can either display an image, output from a command or the contents of a file. Using a combination of these you can get some fairly complex information displayed on your desktop, here is what I was able to achieve in 30 minutes or so:

I've got my IP, last 10 lines from /var/log/system.log, details of my last CCC backup, current usage of the root partition and date/time all on screen at the same time. They all update a varying intervals depending on how often I need it. The system log updates every second and the CCC stats section updates every 30 minutes. Apart from the disk usage (round graphic), everything else I was able to do out of the box. The round graphic above is actually what is called a geeklet, an extension of sorts, but in reality it's a clever apple script which changes to pre-rendered images. It can be downloaded here for those interested.

Some examples of what is seen above:

  • Getting the date of the last CCC backup from command line
    • cat /Library/Logs/CCC.log | grep "Backup Critical Files: Time" | awk '{ print $1 }' | tail -n -1
  • Percentage of disk space used by root partition (i.e. / ) from command line
    • df / | awk '{ print $5 }' | tail -n 1
  • Current IP Address from command line
    • ifconfig en0 | grep inet | awk '{ print $2 }' | tail -n 1

My terrible command line usage aside, the above will allow you display these pieces of information on your desktop via the shell Geeklet.

There are examples of other peoples setups available here if you need some inspiration.

My final note on this great tool is that for some reason, it consumes a stupid amount of memory when you create and modify geeklets. For instance, after creating the above, I noticed it was consuming around 1.2 GB of memory!!! However if you quit GeekTool and start it again, this number drops significantly.

Happy customising!