View Single Post
Posts: 233 | Thanked: 170 times | Joined on Nov 2009 @ Finland
#8
I made my own tweak: A battery percentage line. I put mine on a separate line, but I guess some people would want it at the top with the cpu monitor...

Anyways, here's my addition to conky.conf (I put it before the CPU Usage -line):

${color grey}Battery: $color ${head /home/user/batterylevel 1}%
It simply outputs the first line from the file /home/user/batterylevel, so no exciting connection to a battery-deamon here. I don't think any of Conky's built in battery commands work.

To make /home/user/batterylevel contain the actual battery level, I made the following shell script:

#!/bin/sh
while :
do
lshal | grep battery.charge_level.percentage | awk '{print $3}' > /home/user/batterylevel
sleep 120
done
This one stores the battery charge level in the file /home/user/batterylevel every 120 seconds.

I haven't extensively tested it yet, but it seems to work for me. I also made an init-script for /etc/init.d that launches it at start (you have to symlink it from rc2.d), but I won't start spreading that before I see that there aren't any big problems with this.

Please don't use conky's "exec" to run lshal directly, since both exec and lshal are very resource intensive and will require about 40% cpu all the time just for showing you your battery level!

I would've done this with crontab instead, but there is none and very little information about alternatives that work.
__________________
Read about my N900 experiences from my blog.
 

The Following User Says Thank You to jaysire For This Useful Post: