the Power Management Daemon

Richard Hughes hughsient at
Tue Apr 3 18:18:19 EDT 2007

On Tue, 2007-04-03 at 17:54 -0400, Richard A. Smith wrote:
> Richard Hughes wrote:
> > Sure. There's lots of crazy ideas like the self-battery-profiling code
> > that is being used in g-p-m trunk that may be of interest to you guys.
> > See my blog posts [2] for some of the discussion. The profiling code in
> > particular is *stonkingly* good at profiling old and broken batteries
> > discharge and charge rates and giving an accurate time to charge and
> > discharge.
> Ruh? /me ears perk up.  Tell me a bit more about this profiling code can 
> it run standalone with out g-p-m?

It basically self profiles the charge and discharge cycles, and is
exponentially weighted to increase in in accuracy over time. The time
between percentage points is logged, and the integral taken in either
direction to get the times.

I must admit I've not thought of turning this feature into a library,
although I could do - some of the code is linked pretty hard to g-p-m
due to stuff like multiple battery sources and deciding how to assign
accuracy (and thus weighting) to data points.

I'm ignoring data points that are taken while the load is too high, or
when the backlight is dimmed or off. This means it takes about 4 or 5
discharge-charge cycles to get really accurate.

The code is mostly in src/gpm-profile.c in gnome-power-manager SVN
trunk, although I've not coded the multiple-battery support yet.

For my new lenovo laptop (only exports percentage, no rate) the
discharge time is perfectly linear over 2 hours for charge and
discharge. For my toshiba laptop (one broken cell in the battery) it
still is linear as the profile takes into account the *really*
non-linear discharge and is way more accurate than the "smart" cmos
battery chip.

See some cool screenshots:

And the coolest:
(also attached)

The code is now switched on by default for gnome-power-manager, but is
not optimised at all yet. Comments welcome.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: gpm-tooltip-ss.png
Type: image/png
Size: 12688 bytes
Desc: not available
URL: <>

More information about the Devel mailing list