* 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.*
|
event=button/power.*
|
||||||
action=${powerEventHandler} "%e"
|
action=${powerEventHandler} "%e"
|
||||||
|
|
||||||
|
event=button/lid.*
|
||||||
|
action=${lidEventHandler} "%e"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Called when the power button is pressed.
|
# Called when the power button is pressed.
|
||||||
|
@ -23,6 +26,22 @@ let
|
||||||
exit 0
|
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
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
job = ''
|
job = ''
|
||||||
description "HAL daemon"
|
description "HAL daemon"
|
||||||
|
|
||||||
|
# !!! TODO: make sure that HAL starts after acpid,
|
||||||
|
# otherwise hald-addon-acpi will grab /proc/acpi/event.
|
||||||
start on dbus
|
start on dbus
|
||||||
stop on shutdown
|
stop on shutdown
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue