* Suspend when the laptop lid is closed.

svn path=/nixos/trunk/; revision=14038
This commit is contained in:
Eelco Dolstra 2009-02-11 23:15:07 +00:00
parent c83a185090
commit cf7fcb98ec
2 changed files with 21 additions and 0 deletions

View File

@ -12,6 +12,9 @@ let
''
event=button/power.*
action=${powerEventHandler} "%e"
event=button/lid.*
action=${lidEventHandler} "%e"
'';
# Called when the power button is pressed.
@ -23,6 +26,22 @@ let
exit 0
'';
# Called when the laptop lid is opened/closed.
lidEventHandler = pkgs.writeScript "acpi-lid.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
exit 0
'';
in
{

View File

@ -21,6 +21,8 @@
job = ''
description "HAL daemon"
# !!! TODO: make sure that HAL starts after acpid,
# otherwise hald-addon-acpi will grab /proc/acpi/event.
start on dbus
stop on shutdown