* Suspend when the laptop lid is closed.
svn path=/nixos/trunk/; revision=14038
This commit is contained in:
parent
c83a185090
commit
cf7fcb98ec
@ -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
|
||||
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user