* Suspend when the laptop lid is closed.

svn path=/nixos/branches/fix-style/; revision=14181
This commit is contained in:
Nicolas Pierron 2009-02-22 16:08:28 +00:00
parent 128699688a
commit be4a0494b8
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

@ -44,6 +44,8 @@ let
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