Comment 21 for bug 41994

Andrew Oakley (andrew-aoakley) wrote :

Here's my workaround script which fixes this problem provided you don't have more than one X session (ie. you never use "switch users"). This is a quick and dirty hack which should be replaced by something much cleverer ASAP. Become root and save it as: /etc/acpi/local/

Tested on Ubuntu Hardy Alpha 4 on a Dell Inspiron 1520 only. May or may not work with Gutsy and other prior versions, comment here and let people know. Use at your own risk.

# /etc/acpi/local/ for Ubuntu Hardy Alpha 4 and possibly others
# v0.1 Andrew Oakley 2008-02-02 Public Domain
# Workaround to ensure LCD display remains off on laptops when lid is closed
# even if there is external keyboard/mouse movement (eg. docking station).
# This file should be owned by root and set: chmod 755
# This is a quick and dirty workaround which assumes only ONE X session!
# Also has bug whereby if you close lid, then hibernate/suspend, then resume,
# LCD won't come back on until you re-close and re-open the lid.
export XAUTHORITY=`ls -1 /home/*/.Xauthority`
export DISPLAY=:0
grep -q closed /proc/acpi/button/lid/*/state
if [ $? = 0 ]
  xrandr --output LVDS --off
  xrandr --output LVDS --auto