1 |
Hi, |
2 |
|
3 |
On Mon, 2011-01-31 at 22:09 +0100, Nils Holland wrote: |
4 |
|
5 |
> However, now comes the problem: It seems that whenever I change from |
6 |
> wall power to battery power (probably also vice versa, but I haven't |
7 |
> tested this often enough), the machine's HDD forgets about the |
8 |
> settings I've made using "hdparm" and starts spinning down right again |
9 |
> after only a few seconds of inactivity. That sucks. |
10 |
|
11 |
frustrating indeed! It could be a number of things: gnome, acpi, and/or |
12 |
bios making the changes automatically. |
13 |
|
14 |
My preference would be to fix it in acpid since it will work independent |
15 |
of the window manager or even X. |
16 |
|
17 |
emerge acpid, then edit /etc/acpi/default.sh similarly (sorry about the |
18 |
tabs/spaces): |
19 |
|
20 |
... |
21 |
ac_adapter) |
22 |
case "$value" in |
23 |
*0) |
24 |
# code for unplugging the power |
25 |
echo conservative > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor |
26 |
echo conservative > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor |
27 |
;; |
28 |
*1) |
29 |
# code for plugging in the power |
30 |
echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor |
31 |
echo performance > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor |
32 |
;; |
33 |
... |
34 |
|
35 |
Change (or add) your hdparm commands as required. You could have a |
36 |
different spin-down setting for power and battery if you wish. |
37 |
|
38 |
You'll still have to change the setting after booting, since acpi events |
39 |
usually aren't triggered then. Use local_start() as Paul suggested. If |
40 |
you suspend you may even have to do it after resuming as well. Note |
41 |
that if you use different spin down times you'll need to detect the |
42 |
state of AC before running the hdparm command. Something like this |
43 |
in /usr/local/bin/ should do: |
44 |
|
45 |
#!/bin/sh |
46 |
if ( awk '{print $2}' /proc/acpi/ac_adapter/AC/state | grep on-line ); then |
47 |
# AC adaptor is on-line! |
48 |
echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor |
49 |
echo performance > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor |
50 |
else |
51 |
# AC adaptor is off-line! |
52 |
echo conservative > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor |
53 |
echo conservative > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor |
54 |
fi |
55 |
|
56 |
then call that script from local_start(). |
57 |
|
58 |
HTH! |
59 |
-- |
60 |
Iain Buchanan <iaindb at netspace dot net dot au> |
61 |
|
62 |
I can write better than anybody who can write faster, and I can write |
63 |
faster than anybody who can write better. |
64 |
-- A.J. Liebling |