2 # This script handles all lid events
4 source /etc
/acpi
/eee.conf
6 if [ -S /tmp
/.X11-unix
/X0
]; then
8 user
=$
(who |
grep "vc/7" |
awk '{ if ($(NF) == "(:0)") print $1 }')
11 logger
"Could not verify user for X:"
13 logger
"Falling back to XUSER: $XUSER"
16 logger
"Found X session user: $user"
18 XAUTHORITY
=/home
/$user/.Xauthority
19 [ -f $XAUTHORITY ] && export XAUTHORITY
21 logger
"X not probably running, lets launch the command anyway"
23 XAUTHORITY
=/home
/$user/.Xauthority
24 [ -f $XAUTHORITY ] && export XAUTHORITY
27 lidstate
=$
(cat /proc
/acpi
/button
/lid
/LID
/state |
awk '{print $2}' )
28 ac_state
=$
(cat /proc
/acpi
/ac_adapter
/AC
0/state |
awk '{print $2}' )
29 logger Lid state
: $lidstate
30 logger AC state
: $ac_state
39 if [ "$COMMAND_ON_LID_CLOSE" == "yes" ];
43 # AC adapter plugged in
44 ($ON_AC_LID_CLOSE_ACTION &)
48 ($ON_BATTERY_LID_CLOSE_ACTION &)
52 # if both AC/BATTERY-variables are unset and SUSPEND_SCRIPT is set: execute SUSPEND_SCRIPT
53 # This is for backward compatibility.
54 if [ -z "$ON_AC_LID_CLOSE_ACTION" ] && [ -z "$ON_BATTERY_LID_CLOSE_ACTION" ] && [ -n "$SUSPEND_SCRIPT" ];
61 logger
"Unknown lid state"