0

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?

5 Answers 5

3
+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.

1
  • 1
    Readers : Remember that this answer is from 2009.
    – harrymc
    Commented Jan 23, 2023 at 9:52
2

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.

1
  • Any suggestion on what to do if you screen keeps turning on even though you've shut it off with the above xrandr command? My laptop screen randomly decides to turn itself back on with the resolution all messed up, works fine up to then so it would be nice to be able to force it to stay off.
    – pzkpfw
    Commented May 30, 2017 at 4:58
1

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

0

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

0

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.

1
  • 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
    Commented Dec 2, 2010 at 14:57

You must log in to answer this question.

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