Don't let the mouse wake up displays from standby

There's a great post by @pbm that covers this, over on the Unix SE site.

In short, first use xinput list to get the device ID for your mouse, and then use

xinput --set-prop [ID#] "Device Enabled" "0"

and

xinput --set-prop [ID#] "Device Enabled" "1"

to disable and enable the mouse.

I've just tested these here by disabling the mouse and then calling xset dpms force standby. Waving the mouse around for several seconds did nothing to disturb the screen, but pressing a single key worked fine. Using the second command then returned the mouse back to normal, including the "constant deceleration" setting that my default startup scripts set for me.

You should be able to pass these two commands to the -startCmd and -endCmd options to xlock to get what you're after.


I do it this way in Ubuntu:

#!/bin/bash

# allow only one instance
r=$(pidof -x -o $$ ssmonoff.sh)
set -- $r
if [ "${#@}" -ge 1 ]; then
    echo "Script already running. Exit..."
    exit
fi

dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver'" | ( while read line; do
    if echo $line | grep "boolean true" &> /dev/null; then
            xinput --set-prop "Dell Premium USB Optical Mouse" "Device Enabled" "0"
            xset dpms force off
    else
            xinput --set-prop "Dell Premium USB Optical Mouse" "Device Enabled" "1"
    fi
done )

Some notes:

  • I'm also forcing monitor off.
  • Better use the full name instead of ID.

I hope that this helps.

Tags:

Linux

Gentoo

Dpms