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?

- 14,499

- 6,541
-
Sleep as in blank screen, or sleep as in whole computer? – Sep 11 '15 at 07: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 07:25
-
2You could unplug the mouse when you're not using it... – Daniel Oct 02 '15 at 01:17
-
1If 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 05 '15 at 16:45
-
1I've tried. I turn mouse upside down - it turns itself into proximity sensor :( – Barafu Albino Oct 06 '15 at 07:11
4 Answers
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:
time.sleep(1)
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
The script needs
xprintidle
:sudo apt-get install xprintidle
Copy the script into an empty file, save it as
mouse_toosensitive.py
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).
Test- run it by running it from a terminal window with the command:
python3 /path/to/mouse_toosensitive.py
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"

- 83,767
-
1
-
@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 06 '15 at 07: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 06 '15 at 07:08
-
@DmitryGrigoryev
xprintidle
listens to keyboard- and mouse activities, not to what happens on the screen. – Jacob Vlijm Oct 06 '15 at 07:09 -
@BarafuAlbino But if you uncheck the said checkbox, wouldn't this lead to a worse problem of your screensaver starting in the middle of a movie? – Dmitry Grigoryev Oct 06 '15 at 07:10
-
@JacobVlijm I'm not sure. The
man
page says: "xprintidle
is a utility that queries the X server for the user's idle time and prints it to stdout (in milliseconds)". – Dmitry Grigoryev Oct 06 '15 at 07:11 -
@DmitryGrigoryev it worked in other situations similarly (but another question :)): http://askubuntu.com/questions/524384/how-can-i-keep-the-computer-awake-depending-on-activity/524847#524847 In my tests there, the movie didn't trigger
xprintidle
. The proof of the pudding is the eating however. – Jacob Vlijm Oct 06 '15 at 07:12 -
1@DmitryGrigoryev just tested with
VLC
, the script, usingxprintidle
, happliy disables the mouse, meaning it is insensitive to what happens on screen :) (as I assumed). – Jacob Vlijm Oct 06 '15 at 07:25 -
@JacobVlijm That's great news, your solution covers every need! – Dmitry Grigoryev Oct 06 '15 at 07:30
-
Of course I'm sure you have already experimented with the mouse controls such as:
$ xset mouse [speed] [threshold]
and
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.

- 25,036
-
xset
defines speed, but the problem is - some cases react to any movement, no matter how small or slow. – Barafu Albino Oct 03 '15 at 07: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 03 '15 at 07:47 -
I got an error: "property
'Device Accel Constant Deceleration'
doesn't exist, you need to specify its type and format" – Jonathan Jun 06 '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.

- 1,942
-
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 06 '15 at 06: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 usexscreensaver
, so I'm stuck withxautolock
instead. – Dmitry Grigoryev Oct 06 '15 at 06: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.

- 1