I have bought a gaming mouse with 8200dpi. However, when I use it in Linux I have a problem. When I do not use the PC or watch a video, mouse sometimes generates short moves in response to touching the table or even people walking in the room. Those responses end screensaver and cause video player GUI to show. This is annoying.
What can I do to counter it?

  • Sleep as in blank screen, or sleep as in whole computer? – Kyle Applin Sep 11 '15 at 7:23
  • As a blank screen. Actually, anything that is supposed to stop on mouse move. Mouse is so sensitive, it actually generates move events on slightest vibration. And by default, there is no "minimum travel" to disable screensaver. – Barafu Albino Sep 11 '15 at 7:25
  • 2
    You could unplug the mouse when you're not using it... – Daniel Oct 2 '15 at 1:17
  • 1
    If you're unable to set the mouse DPI (which apparently is not possible), the only solution is probably Jacob Vlijm's script or something similiar. However the quick and dirty hack I use for this is to turn the mouse upside down ;) – kos Oct 5 '15 at 16:45
  • 1
    I've tried. I turn mouse upside down - it turns itself into proximity sensor :( – Barafu Albino Oct 6 '15 at 7:11

A possible solution is the background script below.

What it does

  • After an (arbitrary) idle time, the script will disable the mouse, making it insensitive to whatever you do with it. I would set this relatively short, so there is little chance of disturbance in between.
  • A simple keystroke however (any) will enable the mouse again.

Since xprintidle is triggered by either mouse- or keyboard events (not by what happens on screen), the script will not be disturbed by e.g. playing a movie.

That way, you won't have to fear an unwanted mouse action will disrupt anything, while you still have easy access to the controls and your computer.

As always (and as it should be with background scripts) the script is written in such a way that consumes practically no resources.

The script

#!/usr/bin/env python3
import subprocess
import time
# ---
# set your device (mouse), as found from the command: xinput list
device = 8
# set the desired idle time (in seconds) to disable the mouse
set_idletime = 5
# ---

# don't change anything below
idle1 = 0

while True:
    idle2 = int(int(subprocess.check_output(["xprintidle"]).decode("utf-8").strip())/1000)
    if all([idle1 <= set_idletime, idle2 > set_idletime]):
        subprocess.Popen(["xinput", "set-prop", str(device), "Device Enabled", "0"])
    elif idle2 < idle1:
        subprocess.Popen(["xinput", "set-prop", str(device), "Device Enabled", "1"])
    idle1 = idle2

How to use

  1. The script needs xprintidle:

    sudo apt-get install xprintidle
  2. Copy the script into an empty file, save it as mouse_toosensitive.py

  3. Find out the device (number, integer) of your mouse by running in a terminal:

    xinput list

    In the head section of the script, set both the device number and the desired idle time (see explanation in the script).

  4. Test- run it by running it from a terminal window with the command:

    python3 /path/to/mouse_toosensitive.py
  5. If all works fine, add it to your startup applications: Dash > Startup Applications > Add the command:

    /bin/bash -c "sleep 15 && python3 /path/to/mouse_toosensitive.py"
  • 1
    Now that IS a universal idea. I like it. – Barafu Albino Oct 6 '15 at 6:45
  • @BarafuAlbino could you confirm if this solution works with your media player? My understanding is that most media players trick the X idle time to disable screensavers, which will also prevent this script from running. – Dmitry Grigoryev Oct 6 '15 at 7:06
  • Will try it at Thursday and then report right here. Anyway, I prefer SMplayer, and it has toggleable checkbox for screensaver prevention. – Barafu Albino Oct 6 '15 at 7:08
  • @DmitryGrigoryev xprintidle listens to keyboard- and mouse activities, not to what happens on the screen. – Jacob Vlijm Oct 6 '15 at 7:09
  • 1
    @DmitryGrigoryev just tested with VLC, the script, using xprintidle, happliy disables the mouse, meaning it is insensitive to what happens on screen :) (as I assumed). – Jacob Vlijm Oct 6 '15 at 7:25

Of course I'm sure you have already experimented with the mouse controls such as:

xset mouse

$ xset mouse [speed] [threshold]


Find your input device number

$ xinput
$ xinput --set-prop 9 'Device Accel Constant Deceleration' 3

If experimenting with the available values there doesn't help, try changing your mouse pad to a surface that has more drag. In other words experiment with different type of mouse pads for various sensitivities in that capacity.

  • xset defines speed, but the problem is - some cases react to any movement, no matter how small or slow. – Barafu Albino Oct 3 '15 at 7:05
  • I mentioned the speed and the threshold to make the range so wide to test the limites of no matter how small. Did you test changing the mouse pad surface material to add more friction/drag. – L. D. James Oct 3 '15 at 7:47
  • I got an error: "property 'Device Accel Constant Deceleration' doesn't exist, you need to specify its type and format" – Jonathan Jun 6 '17 at 21:44

If you're using xscreensaver, there's a configuration parameter that fits right in - pointerHysteresis:

If the mouse moves less than this-many pixels in a second, ignore it (do not consider that to be "activity.") This is so that the screen doesn't un-blank (or fail to blank) just because you bumped the desk. Default: 10 pixels.

Another solution I would try is to buy a nice silicone mousepad which may reduce the unwanted motion to a minimum.

  • Good for screensaver, but will require me to set up xscreensaver first. However, I really find video player problem much more annoying. – Barafu Albino Oct 6 '15 at 6:52
  • @BarafuAlbino Yes, this solution is only good for xscreensaver users, and I don't really expect anyone to change their screensaver to apply it. I for one wouldn't be able to use it myself, because my HDMI screen fails to go to standby when I use xscreensaver, so I'm stuck with xautolock instead. – Dmitry Grigoryev Oct 6 '15 at 6:59

Place an ink pen under the back of the mouse to lift the optical sensor above the distance where it will react to movement, remove ink pen when you want to use the mouse again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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