Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a laptop running linux. In my xorg configuration, I have DPMS setup so that the screen automatically turns off during several events. In addition to that I have to the following script tied to ACPI lid open/close events:

#!/bin/sh

for i in $(pidof X); do
        CMD=$(ps --no-heading $i)

        XAUTH="$(echo $CMD | sed -n 's/.*-auth \(.*\)/\1/p')"
        DISPLAY="$(echo $CMD | sed -n 's/.* \(:[0-9]\) .*/\1/p')"

        # turn the display off or back on
        export XAUTHORITY=$XAUTH
        /usr/bin/xset -display $DISPLAY dpms force $1
done

Basically, this script takes one parameter ("on" or "off") then iterates through all of my running X sessions and either turns on or turns off the monitor.

Here's my issue. When I close the lid of the laptop, the screen goes off as expected, but if a mouse event occurs (like if something bumps into the table...) then the screen turns back on even though it is closed (I can see the light through the side of the laptop).

Is there a way to prevent the screen from turning on during a mouse event if the lid is closed?

share|improve this question

6 Answers 6

up vote 3 down vote accepted
+50

Add the following lines to the /etc/acpi/lid.sh file:

#open
screenon
chvt 7
#close
chvt 12
screenoff

This will switch to console when the lid is closed and avoid X detecting mouse movements.

share|improve this answer

Following the idea of disabling the mouse, you can do it in a more selective and secure manner with xinput:

# open
DISPLAY=:0.0 xinput set-int-prop 12 "Device Enabled" 8 1
# close
DISPLAY=:0.0 xinput set-int-prop 12 "Device Enabled" 8 0

You find the ID (12 here) with: xinput --list

share|improve this answer

You might be able to do some magic with xrandr; e.g. something along the lines of

xrandr --output LVDS --off

to switch it off, and

xrandr --output LVDS --auto

to bring it back. Replace LVDS with whatever the name of the output to your laptop's screen is.

The downside with this, is that if something goes wrong it might be hard to get your screen back short of power cycling.

share|improve this answer

Try using an app like Power Devil to manage that. KDE or Gnome?

share|improve this answer

It seems to be a bit difficult to prevent X from signalling activity and disabling DPMS when it receives activity events.

But, since you are already in the scripting realm, how about just disabling the usb devices when the lid is closed? The effect could be achieved by simply removing modules, or perhaps suspending the usb device. Something like this might work:

echo suspend > /sys/bus/usb/devices/usb1/power/level

If this works, your X will not receive any events while the lid is closed.

share|improve this answer
    
This is rather drastic, and seems dangerous. There might be other USB devices attached (printer, memory stick, GSM modem), and killing their connection will probably lead to problems. –  sleske Dec 2 '10 at 14:57

I gave up finding a real solution and ended up coding the following in bash:

while lid is closed {
    turn off screen;
    sleep 5;
}

I'll see if I can find the actual script and post it here.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.