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/lid.sh.pre

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.

#!/bin/sh
# /etc/acpi/local/lid.sh.pre for Ubuntu Hardy Alpha 4 and possibly others
# v0.1 Andrew Oakley www.aoakley.com 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 ]
then
  xrandr --output LVDS --off
else
  xrandr --output LVDS --auto
fi