[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Common power management infrastructure

Hi y'all,

I have a proposition to make, and I hope you'll listen. The short story:
I think power management in Debian is not well-integrated and a pain to
configure. Read on for the long story, and for a proposal on how to
improve the situation.

While I was working on the laptop-mode-tools package, I noticed already
that there's no generic way to do power management. It doesn't matter if
you have APM, ACPI, PMU, pbbuttons, or some other power management
daemon, you have to put event handling scripts in wildly different
places to make power management work. Now that I've finally got my hands
on a laptop (yes, I've been working on laptop mode without ever having
one :) ) I've noticed another thing, and that's that there is no generic
way to apply power management policies _at bootup time_. All of the
daemons listed above only provide _event_ interfaces (e.g. "AC power was
just unplugged") only, not _state_ interfaces (e.g. "the computer is
currently running on batteries, and I'm not telling you whether the
cable was just unplugged, whether we just booted up, or whether we just
resumed from hibernation"). For laptop-mode-tools I've fixed this by
adding an init script of my own, but when I was configuring my laptop I
was very irritated by the fact that I had to add init scripts for
_everything_ that I also did in the event scripts.

Now, I'm hoping to get an agreement from all the guys I've CC'ed (the
maintainers of acpid, apmd, pmud and pbbuttonsd) that this situation
needs fixing. Here are my thoughts:

* We need a shared, state-based structure for the basic power management
functionality. I propose to use /etc/powermgmt/ as the configuration
directory, with subdirectories for events. I'm thinking of
subdirectories power-source.d (scripts that handle power source changes
-- battery versus AC), lid.d (scripts that are called on lid
open/close), power-button.d (scripts that are called when the power
button is pressed), battery-charge.d (scripts that are called when the
amount of charge in the battery changes). Are there any categories I've

* All the other daemons need to include scripts that trigger the common
interface's events. I know this is pretty easy to do for ACPI, I don't
know about the other daemons. There might be daemons with only partial

* The logical place for the shared infrastructure is in powermgmt-base.
This should contain init scripts which would detect the power source
(for power saving) and call the /etc/powermgmt/power-source.d scripts
appropriately. That way, the laptop is put in the right mode at boot
time as well as when a power source change occurs.

* There could be separate packages with various features, that could
hook into the shared infrastructure. Laptop mode is only one of them.
There could be laptop-specific (e.g., based on toshset and/or toshutils
for Toshiba laptops) packages that would work regardless of APM/ACPI.
There could also be convenient "policy" packages that would set the
system up in a specific way based on power state, i.e. stop certain
services and start others.

I'd like to hear everybody's comments on the ideas I've written up. If
we can come to an agreement on what is to be done, I'll gladly volunteer
some of my time for building something like this. The only thing that I
need is cooperation from the various people maintaining the various
power management packages, because integrating the stuff in their
packages is crucial for the success of an operation like this.

Bart Samwel <bart@samwel.tk>

Reply to: