Hi,

On Mon, 2011-01-31 at 22:09 +0100, Nils Holland wrote:

> However, now comes the problem: It seems that whenever I change from
> wall power to battery power (probably also vice versa, but I haven't
> tested this often enough), the machine's HDD forgets about the
> settings I've made using "hdparm" and starts spinning down right again
> after only a few seconds of inactivity. That sucks.

frustrating indeed!  It could be a number of things: gnome, acpi, and/or
bios making the changes automatically.

My preference would be to fix it in acpid since it will work independent
of the window manager or even X.

emerge acpid, then edit /etc/acpi/default.sh similarly (sorry about the
tabs/spaces):

...
        ac_adapter)
                case "$value" in
          *0)
              # code for unplugging the power
              echo conservative > 
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
              echo conservative > 
/sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
              ;;
          *1)
              # code for plugging in the power
              echo performance > 
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
              echo performance > 
/sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
              ;;
...

Change (or add) your hdparm commands as required.  You could have a
different spin-down setting for power and battery if you wish.

You'll still have to change the setting after booting, since acpi events
usually aren't triggered then.  Use local_start() as Paul suggested.  If
you suspend you may even have to do it after resuming as well.  Note
that if you use different spin down times you'll need to detect the
state of AC before running the hdparm command.  Something like this
in /usr/local/bin/ should do:

#!/bin/sh
if ( awk '{print $2}' /proc/acpi/ac_adapter/AC/state | grep on-line ); then
    # AC adaptor is on-line!
    echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
    echo performance > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
else
    # AC adaptor is off-line!
    echo conservative > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
    echo conservative > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
fi

then call that script from local_start().

HTH!
-- 
Iain Buchanan <iaindb at netspace dot net dot au>

I can write better than anybody who can write faster, and I can write
faster than anybody who can write better.
                -- A.J. Liebling


Reply via email to