* 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
@ -3033,7 +3033,20 @@ root ALL=(ALL) SETENV: ALL
|
|||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
powerManagement = {
|
||||||
|
|
||||||
|
enable = mkOption {
|
||||||
|
default = false;
|
||||||
|
description = "
|
||||||
|
Whether to enable power management.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
nesting = {
|
nesting = {
|
||||||
children = mkOption {
|
children = mkOption {
|
||||||
default = [];
|
default = [];
|
||||||
@ -3043,6 +3056,7 @@ root ALL=(ALL) SETENV: ALL
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
passthru = mkOption {
|
passthru = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
description = "
|
description = "
|
||||||
|
@ -15,6 +15,9 @@ let
|
|||||||
|
|
||||||
event=button/lid.*
|
event=button/lid.*
|
||||||
action=${lidEventHandler} "%e"
|
action=${lidEventHandler} "%e"
|
||||||
|
|
||||||
|
event=ac_adapter.*
|
||||||
|
action=${acEventHandler} "%e"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Called when the power button is pressed.
|
# Called when the power button is pressed.
|
||||||
@ -23,7 +26,6 @@ let
|
|||||||
#! ${pkgs.bash}/bin/sh
|
#! ${pkgs.bash}/bin/sh
|
||||||
# Suspend to RAM.
|
# Suspend to RAM.
|
||||||
#echo mem > /sys/power/state
|
#echo mem > /sys/power/state
|
||||||
exit 0
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Called when the laptop lid is opened/closed.
|
# Called when the laptop lid is opened/closed.
|
||||||
@ -38,8 +40,18 @@ let
|
|||||||
sync
|
sync
|
||||||
echo mem > /sys/power/state
|
echo mem > /sys/power/state
|
||||||
fi
|
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
|
in
|
||||||
|
@ -343,7 +343,7 @@ let
|
|||||||
})
|
})
|
||||||
|
|
||||||
# ACPI daemon.
|
# ACPI daemon.
|
||||||
++ optional true /* !!! need some option */
|
++ optional config.powerManagement.enable
|
||||||
(import ../upstart-jobs/acpid.nix {
|
(import ../upstart-jobs/acpid.nix {
|
||||||
inherit config pkgs;
|
inherit config pkgs;
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user