* Generate the acpid configuration properly: each config file
can only contain one event. svn path=/nixos/branches/fix-style/; revision=14183
This commit is contained in:
parent
094aee7467
commit
802d4f02c4
@ -5,31 +5,36 @@ let
|
|||||||
acpiConfDir = pkgs.runCommand "acpi-events" {}
|
acpiConfDir = pkgs.runCommand "acpi-events" {}
|
||||||
''
|
''
|
||||||
ensureDir $out
|
ensureDir $out
|
||||||
ln -s ${acpiConfFile} $out/events.conf
|
${
|
||||||
'';
|
# Generate a .conf file for each event. (You can't have
|
||||||
|
# multiple events in one config file...)
|
||||||
acpiConfFile = pkgs.writeText "acpi.conf"
|
let f = event:
|
||||||
''
|
''
|
||||||
event=button/power.*
|
fn=$out/${event.name}.conf
|
||||||
action=${powerEventHandler} "%e"
|
echo "event=${event.event}" > $fn
|
||||||
|
echo "action=${pkgs.writeScript "${event.name}.sh" event.action}" >> $fn
|
||||||
event=button/lid.*
|
|
||||||
action=${lidEventHandler} "%e"
|
|
||||||
|
|
||||||
event=ac_adapter.*
|
|
||||||
action=${acEventHandler} "%e"
|
|
||||||
'';
|
'';
|
||||||
|
in pkgs.lib.concatMapStrings f events
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
|
||||||
|
events = [powerEvent lidEvent acEvent];
|
||||||
|
|
||||||
# Called when the power button is pressed.
|
# Called when the power button is pressed.
|
||||||
powerEventHandler = pkgs.writeScript "acpi-power.sh"
|
powerEvent =
|
||||||
|
{ name = "power-button";
|
||||||
|
event = "button/power.*";
|
||||||
|
action =
|
||||||
''
|
''
|
||||||
#! ${pkgs.bash}/bin/sh
|
#! ${pkgs.bash}/bin/sh
|
||||||
# Suspend to RAM.
|
|
||||||
#echo mem > /sys/power/state
|
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
# Called when the laptop lid is opened/closed.
|
# Called when the laptop lid is opened/closed.
|
||||||
lidEventHandler = pkgs.writeScript "acpi-lid.sh"
|
lidEvent =
|
||||||
|
{ name = "lid";
|
||||||
|
event = "button/lid.*";
|
||||||
|
action =
|
||||||
''
|
''
|
||||||
#! ${pkgs.bash}/bin/sh
|
#! ${pkgs.bash}/bin/sh
|
||||||
|
|
||||||
@ -41,9 +46,13 @@ let
|
|||||||
echo mem > /sys/power/state
|
echo mem > /sys/power/state
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
# Called when the AC power is connected or disconnected.
|
# Called when the AC power is connected or disconnected.
|
||||||
acEventHandler = pkgs.writeScript "ac-power.sh"
|
acEvent =
|
||||||
|
{ name = "ac-power";
|
||||||
|
event = "ac_adapter.*";
|
||||||
|
action =
|
||||||
''
|
''
|
||||||
#! ${pkgs.bash}/bin/sh
|
#! ${pkgs.bash}/bin/sh
|
||||||
|
|
||||||
@ -53,6 +62,7 @@ let
|
|||||||
echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
|
echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user