X11 Laptop Battery Monitor for the n140 (and others)

This is a small Perl scripted battery monitor that displays the battery state (chargind, discharging) using TK. It also tries to estimate remaining time in minutes until empty or full charge from the current capacity and change rate.

It may be useful for other laptops as well, I originally wrote it for my ThinkPad x31. Basically what you need to do is to check whether there is usefull information in

And then adapt the script to parse it. The battery number may be different, on the x31 it was BAT0.

Source code is here: batt_mon

The charging state looks like this (75% charged, 115 minutes to full):

charging state

Discharging looks like this (75% charged, 306 minutes to empty):

discharging state

The color changes to yellow at 30% and red at 10%. This can be adapted around line 90 in the script.

Update rate is every 10 seconds. Can be changed in Line 37.

X11 Integration

I use the following line in the InitFunction of my .fvwmrc, which places the display at the lower right side. Adapt for your window manager.
 +       "I" Exec exp/perl/tk/batt_mon -geometry 140x20-172-0 &

Last update: January, 2010 Arno Wagner