Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:


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

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
up vote 3 down vote accepted

Add the following lines to the /etc/acpi/ file:

chvt 7
chvt 12

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .