* acpid: switch to the ondemand CPU scaling governer when on battery power.
Disabled acpid by default because it's not configurable enough yet. svn path=/nixos/trunk/; revision=14070
This commit is contained in:
parent
cf7fcb98ec
commit
03e7f296b1
3 changed files with 29 additions and 3 deletions
|
@ -3033,7 +3033,20 @@ root ALL=(ALL) SETENV: ALL
|
|||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
powerManagement = {
|
||||
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether to enable power management.
|
||||
";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
nesting = {
|
||||
children = mkOption {
|
||||
default = [];
|
||||
|
@ -3043,6 +3056,7 @@ root ALL=(ALL) SETENV: ALL
|
|||
};
|
||||
};
|
||||
|
||||
|
||||
passthru = mkOption {
|
||||
default = {};
|
||||
description = "
|
||||
|
|
|
@ -15,6 +15,9 @@ let
|
|||
|
||||
event=button/lid.*
|
||||
action=${lidEventHandler} "%e"
|
||||
|
||||
event=ac_adapter.*
|
||||
action=${acEventHandler} "%e"
|
||||
'';
|
||||
|
||||
# Called when the power button is pressed.
|
||||
|
@ -23,7 +26,6 @@ let
|
|||
#! ${pkgs.bash}/bin/sh
|
||||
# Suspend to RAM.
|
||||
#echo mem > /sys/power/state
|
||||
exit 0
|
||||
'';
|
||||
|
||||
# Called when the laptop lid is opened/closed.
|
||||
|
@ -38,8 +40,18 @@ let
|
|||
sync
|
||||
echo mem > /sys/power/state
|
||||
fi
|
||||
'';
|
||||
|
||||
exit 0
|
||||
# Called when the AC power is connected or disconnected.
|
||||
acEventHandler = pkgs.writeScript "ac-power.sh"
|
||||
''
|
||||
#! ${pkgs.bash}/bin/sh
|
||||
|
||||
if grep -q "state:.*on-line" /proc/acpi/ac_adapter/AC/state; then
|
||||
echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
|
||||
elif grep -q "state:.*off-line" /proc/acpi/ac_adapter/AC/state; then
|
||||
echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
|
||||
fi
|
||||
'';
|
||||
|
||||
in
|
||||
|
|
|
@ -343,7 +343,7 @@ let
|
|||
})
|
||||
|
||||
# ACPI daemon.
|
||||
++ optional true /* !!! need some option */
|
||||
++ optional config.powerManagement.enable
|
||||
(import ../upstart-jobs/acpid.nix {
|
||||
inherit config pkgs;
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue