Mouse is too sensitive - disrupts sleep
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"
Of course I'm sure you have already experimented with the mouse controls such as:
xset mouse
$ 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.
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.