HunterZ

Ubuntu ACPI lid fix

Jun 3rd, 2015
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.25 KB | None | 0 0
  1. #/etc/acpi/events/lidbtn:
  2. #----------------------------------------------
  3. # /etc/acpi/events/lidbtn
  4. # Called when the user closes or opens the lid
  5.  
  6. event=button[ /]lid
  7. action=/etc/acpi/lid.sh
  8. #----------------------------------------------
  9.  
  10.  
  11. #/etc/acpi/lid.sh (be sure to set execute permissions):
  12. #----------------------------------------------
  13. #!/bin/bash
  14.  
  15. export DISPLAY=":0.0"
  16. export XAUTHORITY=$(/bin/ps -ef | /bin/egrep ':[0-9][0-9] /usr/bin/X' | /bin/sed 's/^.*auth//' | /usr/bin/awk '{print $1}')
  17. LIDSTATE=$(/usr/bin/awk '{print $2}' /proc/acpi/button/lid/LID/state)
  18. /usr/bin/logger "Start: STATE=$LIDSTATE DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY"
  19.  
  20. while [[ "$LIDSTATE" == "closed" ]]; do
  21.     MONSTATE=$(xset q | grep "Monitor is" | awk '{print $NF}')
  22. #    /usr/sbin/vbetool dpms off
  23.     if [[ "$MONSTATE" == "On" ]]; then
  24.         /usr/bin/logger "Force: STATE=$LIDSTATE DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY"
  25.         /usr/bin/xset dpms force off
  26.     fi
  27.     /bin/sleep 1
  28.     LIDSTATE=$(/usr/bin/awk '{print $2}' /proc/acpi/button/lid/LID/state)
  29. done
  30.  
  31. /usr/bin/logger "End: STATE=$LIDSTATE DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY"
  32. #/usr/sbin/vbetool dpms on
  33. /usr/bin/xset dpms force on
  34. #----------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment