Comment 11 for bug 108611

Revision history for this message
mannheim (kronheim) wrote :

This is the situation in intrepid, I think:

The script /etc/acpi/power.sh seems to be called whenever the AC power is plugged in or removed, and it is also called at boot up (via the init script /etc/init.d/acpi-support) and when resuming from suspend. This is okay.

However, the script /etc/acpi/power.sh checks whether the power state has actually changed, using the function checkStateChanged(). This function does "exit 0" if the state has not changed. If the state has changed, then the power.sh script runs all the scripts in either /etc/acpi/battery.d or /etc/acpi/ac.d, as appropriate.

This works fine for plugging in and unplugging the power, and at resume from suspend. It does not work at boot time, however, because the checkStateChanged function is irrelevant at boot time. This is the thought behind msrgi's modification. I think a simpler way to deal with it is to change /etc/init.d/acpi-support by adding a line:

case "$1" in
  start)
    log_begin_msg "Checking battery state..."
    if [ -f "$POWERSTATE" ]; then rm "$POWERSTATE"; fi
    /etc/acpi/power.sh
   ...... etc ....

The result should be that the init script will always call the scripts in either /etc/acpi/battery.d or /etc/acpi/ac.d on startup.