mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-09-22 04:57:56 +03:00
* Remove the ACPI actions. There's obsolete now (handled by HAL /
pm-utils / KDE). svn path=/nixos/trunk/; revision=17495
This commit is contained in:
parent
636a9e7e32
commit
d142b8a13b
@ -1,21 +1,6 @@
|
|||||||
{pkgs, config, ...}:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
###### interface
|
with pkgs.lib;
|
||||||
let
|
|
||||||
inherit (pkgs.lib) mkOption mkIf;
|
|
||||||
|
|
||||||
options = {
|
|
||||||
powerManagement = {
|
|
||||||
|
|
||||||
enable = mkOption {
|
|
||||||
default = false;
|
|
||||||
description = "Whether to enable power management (ACPI daemon)";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
|
|
||||||
###### implementation
|
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
@ -35,6 +20,8 @@ let
|
|||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
events = [powerEvent lidEvent acEvent];
|
||||||
|
|
||||||
# Called when the power button is pressed.
|
# Called when the power button is pressed.
|
||||||
powerEvent =
|
powerEvent =
|
||||||
{ name = "power-button";
|
{ name = "power-button";
|
||||||
@ -52,14 +39,6 @@ let
|
|||||||
action =
|
action =
|
||||||
''
|
''
|
||||||
#! ${pkgs.bash}/bin/sh
|
#! ${pkgs.bash}/bin/sh
|
||||||
|
|
||||||
# Suspend to RAM if the lid is closed. (We also get this event
|
|
||||||
# when the lid just opened, in which case we obviously don't
|
|
||||||
# want to suspend again.)
|
|
||||||
if grep -q closed /proc/acpi/button/lid/LID/state; then
|
|
||||||
sync
|
|
||||||
echo mem > /sys/power/state
|
|
||||||
fi
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -70,36 +49,43 @@ let
|
|||||||
action =
|
action =
|
||||||
''
|
''
|
||||||
#! ${pkgs.bash}/bin/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
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
events = [powerEvent lidEvent acEvent];
|
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
mkIf config.powerManagement.enable {
|
{
|
||||||
require = [
|
|
||||||
options
|
|
||||||
];
|
|
||||||
|
|
||||||
services = {
|
###### interface
|
||||||
extraJobs = [{
|
|
||||||
name = "acpid";
|
|
||||||
|
|
||||||
job = ''
|
options = {
|
||||||
description "ACPI daemon"
|
|
||||||
|
powerManagement = {
|
||||||
|
|
||||||
start on udev
|
enable = mkOption {
|
||||||
stop on shutdown
|
default = false;
|
||||||
|
description = "Whether to enable power management (ACPI daemon)";
|
||||||
respawn ${pkgs.acpid}/sbin/acpid --foreground --confdir ${acpiConfDir}
|
};
|
||||||
'';
|
|
||||||
}];
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
###### implementation
|
||||||
|
|
||||||
|
config = mkIf config.powerManagement.enable {
|
||||||
|
|
||||||
|
jobs = singleton
|
||||||
|
{ name = "acpid";
|
||||||
|
description = "ACPI daemon";
|
||||||
|
|
||||||
|
startOn = "udev";
|
||||||
|
stopOn = "shutdown";
|
||||||
|
|
||||||
|
exec = "${pkgs.acpid}/sbin/acpid --foreground --confdir ${acpiConfDir}";
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user