Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #/etc/acpi/events/lidbtn:
- #----------------------------------------------
- # /etc/acpi/events/lidbtn
- # Called when the user closes or opens the lid
- event=button[ /]lid
- action=/etc/acpi/lid.sh
- #----------------------------------------------
- #/etc/acpi/lid.sh (be sure to set execute permissions):
- #----------------------------------------------
- #!/bin/bash
- export DISPLAY=":0.0"
- export XAUTHORITY=$(/bin/ps -ef | /bin/egrep ':[0-9][0-9] /usr/bin/X' | /bin/sed 's/^.*auth//' | /usr/bin/awk '{print $1}')
- LIDSTATE=$(/usr/bin/awk '{print $2}' /proc/acpi/button/lid/LID/state)
- /usr/bin/logger "Start: STATE=$LIDSTATE DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY"
- while [[ "$LIDSTATE" == "closed" ]]; do
- MONSTATE=$(xset q | grep "Monitor is" | awk '{print $NF}')
- # /usr/sbin/vbetool dpms off
- if [[ "$MONSTATE" == "On" ]]; then
- /usr/bin/logger "Force: STATE=$LIDSTATE DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY"
- /usr/bin/xset dpms force off
- fi
- /bin/sleep 1
- LIDSTATE=$(/usr/bin/awk '{print $2}' /proc/acpi/button/lid/LID/state)
- done
- /usr/bin/logger "End: STATE=$LIDSTATE DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY"
- #/usr/sbin/vbetool dpms on
- /usr/bin/xset dpms force on
- #----------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment