GeekTools, desktop enhancing
A friend of mine, Micke, showed me the app "GeekTool" yesterday, and I stuck for it imediatly.
The app is really great. It lets you use terminal commands to show certain data on your desktop. I started using it right away, and this is my result:
Geektool 2.1.2 can be downloaded here: http://www.versiontracker.com/dyn/moreinfo/macosx/17621
Now, ofcourse not everybody is good in shell scripting and/or terminal commands to I show you the commands below:
For IP address (Internal):
ifconfig en0 | awk '/inet / {print "[IP]\t\t\t" $2}'
For Uptime:
uptime | awk '{print "[Uptime]\t\t" $3 " " $4 " " $5 }' | sed -e 's/.$//g'
For HD free space:
df -hl | grep 'disk0s2' | awk '{print "[HD]\t\t\t"$4"/"$2" free ("$5" used)"}'
For RAM usage:
top -l 1 | awk '/PhysMem/ {print "[RAM]\t\tUsed: " $8 " Free: " $10}'
For the clock: (set refresh to 1)
date '+%H:%M:%S'
For the battery:
The battery is a litte bit more tricky one, I wrote a little sh script.
First off, I created a directory in my Documents folder called "geektools". In that directory I created a text-file called "battery.sh".
When you have created this file, add the folowing text to it:
#!/bin/bash maxcap=`ioreg -l | grep Capacity |awk '/MaxCapacity/{print $5}'` curcap=`ioreg -l | grep Capacity |awk '/CurrentCapacity/{print $5}'` curcap=`echo $curcap*1000|bc` proc=`echo $curcap / $maxcap |bc`; len=`echo ${#proc}`; proc_num=${proc:0:3} proc_dec=${proc:3:4} proc_num_len=`echo ${#proc_num}`; if [ $proc_num_len == "3" ]; then if [ $proc_num != "100" ]; then proc_num=${proc:0:2} proc_dec=${proc:2:3} fi fi echo $proc_num.$proc_dec%
Now, in geektools add the following command:
echo "[Battery] " `sh /Users/paulp/Documents/geektools/battery.sh`
Remember to change the path to the correct path to your file.
This is the result (a little smaler image):

If you have to scripts/commands/tips of your own, please add them as an comment!
Cheers,
/Paul
May 28th, 2009 at 11:54
I made a little update to the battery script. There was a problem when the battery was fully loaded, it would say 10.00% instead of 100.0%.
change:
to:
Regards,
Paul
May 28th, 2009 at 11:57
Nice!
May 28th, 2009 at 16:39
Trevligt! Ser skitbra ut. Om du lyckas få in Yahoo-väder så säg till, har trilskats med det ett tag nu och det vill inte lyda mig!
May 28th, 2009 at 16:41
=P
http://www.flickr.com/photos/woodztream/3570233859/
June 3rd, 2009 at 20:21
Thanks… this was helpful.
June 5th, 2009 at 12:20
I updated the batteryscript once more… though it still had a bug.
This is the new script (even updated in the main post):
September 26th, 2009 at 20:21
Thanks! The battery works well! As a background to that stat I added this image:
http://www.loganrockmore.com/StatusScreenSaver/images/modules/battery.png
Thanks again!
October 5th, 2009 at 17:25
I’m not sure if this is going to embed in the comment correctly, but this is what I came up with after tweaking yours a little. A few notes:
* I’ve never seen, let alone written, shell scripting, so I’m sure this is really poor. I would love input.
* Mine is calculating health based on a fixed number in the script. 5500, I think, is the original capacity of my MBP’s battery.
* I created a cute little battery display. $starcount_size lets you customize how wide the display is.
Thanks for your original!!!
#!/bin/bash
maxcap=`ioreg -l | grep Capacity |awk ‘/MaxCapacity/{print $5}’`
curcap=`ioreg -l | grep Capacity |awk ‘/CurrentCapacity/{print $5}’`
procint=`echo scale=2\;$curcap / $maxcap*100|bc`;
procint_length=`echo ${#procint}-3|bc`;
procint=${procint:0:$procint_length};
procprc=`echo $proc-$procint|bc`;
procprc_length=`echo ${#procprc}-2|bc`;
if [ $procprc_length -lt 0 ]; then
$procprc_length=0;
fi
procprc=${procprc:0:$procprc_length};
maxhealth=5500;
health=`echo $maxcap/$maxhealth*100|bc -l`;
health=${health:0:2}
starcount_size=3;
starcount=`echo $procint/$starcount_size|bc`;
starcount_totalsize=`echo 100/$starcount_size|bc`
starcount_inv=`echo $starcount_totalsize-$starcount|bc`;
echo “[\c";
COUNTER=0
while [ $COUNTER -lt $starcount ]; do
echo “o\c”;
let COUNTER=COUNTER+1
done
COUNTER=0
while [ $COUNTER -lt $starcount_inv ]; do
echo “•\c”;
let COUNTER=COUNTER+1
done
echo “]”;
echo “Battery: “$procint$procprc%” (“$curcap/$maxcap”)\nHealth: “$health%;
October 5th, 2009 at 18:26
The script I posted before was missing a line. Sorry!
I’m not sure if this is going to embed in the comment correctly, but this is what I came up with after tweaking yours a little. A few notes:
* I’ve never seen, let alone written, shell scripting, so I’m sure this is really poor. I would love input.
* Mine is calculating health based on a fixed number in the script. 5500, I think, is the original capacity of my MBP’s battery.
* I created a cute little battery display. $starcount_size lets you customize how wide the display is.
Thanks for your original!!!
#!/bin/bash
maxcap=`ioreg -l | grep Capacity |awk ‘/MaxCapacity/{print $5}’`
curcap=`ioreg -l | grep Capacity |awk ‘/CurrentCapacity/{print $5}’`
proc=`echo scale=3\;$curcap / $maxcap*100 |bc`;
procint=`echo scale=2\;$curcap / $maxcap*100|bc`;
procint_length=`echo ${#procint}-3|bc`;
procint=${procint:0:$procint_length};
procprc=`echo $proc-$procint|bc`;
procprc_length=`echo ${#procprc}-2|bc`;
if [ $procprc_length -lt 0 ]; then
$procprc_length=0;
fi
procprc=${procprc:0:$procprc_length};
maxhealth=5500;
health=`echo $maxcap/$maxhealth*100|bc -l`;
health=${health:0:2}
starcount_size=3;
starcount=`echo $procint/$starcount_size|bc`;
starcount_totalsize=`echo 100/$starcount_size|bc`
starcount_inv=`echo $starcount_totalsize-$starcount|bc`;
echo “[\c";
COUNTER=0
while [ $COUNTER -lt $starcount ]; do
echo “o\c”;
let COUNTER=COUNTER+1
done
COUNTER=0
while [ $COUNTER -lt $starcount_inv ]; do
echo “•\c”;
let COUNTER=COUNTER+1
done
echo “]”;
echo “Battery: “$procint$procprc%” (“$curcap/$maxcap”)\nHealth: “$health%;
October 5th, 2009 at 18:34
Great! Thanks alot! I will check it later today.
Cheers
/Paul
October 5th, 2009 at 18:44
Paul, I’m really bad, but the line that says $procprc_length=0; should instead say procprc_length=0;
I just thought to check the console for errors and noticed a few.. that’s why I noticed the first error and then this one. Sorry. Feel free to delete all of these comments and just put the final, working script online… or edit as you feel fit.
October 5th, 2009 at 18:56
No worries… I will change the post later and remove the first comment.
Third time is a charm, right?
Cheers,
/Paul
January 23rd, 2010 at 15:06
Hello,
Matt or Paul one question please :
I implemented the script of Matt but i not the percentage of the battery that appears ?
Thanks for help
Best regard
March 9th, 2010 at 9:30
Allright… I’ll have a look at it next week…. need to reinstall my mac first.