Hello again, intrigeri wrote (22 Jun 2008 21:29:13 GMT) : > Well, that’s a good starting point, but... a bit too ad-hoc for my > taste. There are not only ACPI laptops, but also APM, PMU, and maybe > some more. IMHO, a more generic way should be used to tell if the box > is running on battery power.
> Does Debian, or the Linux kernel, already provides a generic interface > for this ? If not, maybe another program / lib already does this. > If not, we may have to invent our own wheel. The powermgmt-base package contains a /sbin/on_ac_power shell script that manages ACPI, PMU and APM. The issue is... in case of ACPI, it looks for the /proc/acpi/ac_adapter directory, that does not exist on my desktop machine, and thus exits with code 255 (i.e. « Power status could not be determined », according to the manpage). Adam’s solution has the same issue : $ acpi -a No support for device type: battery No support for device type: ac_adapter $ acpi -a | grep 'on-line' $ I don’t know if this is specific to the two desktop boxes I’ve run these tests on, but it seems that non-laptop boxes have no way to tell if they are running on AC power... which seems quite logical, since they obviously are. My proposal is then to : - use the runonbattery option suggested by Adam, defaulting to "yes" as Adam’s did - in case runonbattery is set to "no", use powermgmt-base’s on_ac_power script to determine if the box is running on battery - suggest the powermgmt-base package - well-document the dependancy of runonbattery option on powermgmt-base package A thing I’m not sure about is : do we really want to make this option a per-job one ? It adds a bit of complexity to the user-configuration that I’m not sure we want to add. Adam, could you please provide us with an example of which jobs you may want to run on battery, and which ones you don’t ? Bye, -- intrigeri <[EMAIL PROTECTED]> | gnupg key @ http://gaffer.boum.org/intrigeri/intrigeri.asc | So what? -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]