This is even more annoying when I am sitting at my desk, with my mouse plugged.
I know that there is a setting to disable the mousepad when typing but I wanted something more robust.
For this reason here is a little guide about how I managed to automatically disable the mousepad when I plug in a usb mouse and how to enable it back when I unplug it.
You need some utility to query your mice.
1 | sudo yum install xorg-x11-apps |
Now we can have a list of the recognized plugged input devices on your system:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | $ xinput list ⎡ Virtual core pointer id =2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id =4 [slave pointer (2)] ⎜ ↳ TPPS /2 IBM TrackPoint id =13 [slave pointer (2)] ⎜ ↳ Macintosh mouse button emulation id =14 [slave pointer (2)] ⎜ ↳ Logitech USB Laser Mouse id =16 [slave pointer (2)] ⎜ ↳ SynPS /2 Synaptics TouchPad id =15 [slave pointer (2)] ⎣ Virtual core keyboard id =3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id =5 [slave keyboard (3)] ↳ ThinkPad Extra Buttons id =6 [slave keyboard (3)] ↳ AT Translated Set 2 keyboard id =7 [slave keyboard (3)] ↳ Lid Switch id =8 [slave keyboard (3)] ↳ Integrated Camera id =9 [slave keyboard (3)] ↳ Sleep Button id =10 [slave keyboard (3)] ↳ Video Bus id =11 [slave keyboard (3)] ↳ Power Button id =12 [slave keyboard (3)] |
My laptop has a touchpad(id=15) and a trackpoint(id=13).
And you can see an entry for my usb mouse (id=16)
If you just want to disable manually the mousepad or any other device it is quite easy.
It is just a matter of:
1 2 | xinput -- set -prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 1 # to enable xinput -- set -prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 0 # to disable |
Now if we want to automatically execute this commands when the mouse is plugged/unplugged we need to use udev.
1 | sudo yum install udev |
We create a new rules file in udev configuration folder:
1 | sudo gedit /etc/udev/rules .d /61-touchpad .rules |
And add this code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # 61-touchpad.rules # # this rules file must be named 61* or later because it won't work # unless it runs after '/lib/udev/rules.d/60-persistent-input.rules' # # NOTE: will only affect DISPLAY :0 # # run: # udevadm test --action=add /sys/devices/platform/i8042/serio1/input/input6/mouse1 # or similar to test the following rules # ACTION== "add" , SUBSYSTEM== "input" , ENV{DISPLAY}= ":0.0" , DEVPATH== "*/mouse?" , RUN+= "/usr/bin/xinput --set-prop 'SynPS/2 Synaptics TouchPad' 'Device Enabled' 0" ACTION== "remove" , SUBSYSTEM== "input" , ENV{DISPLAY}= ":0.0" , DEVPATH== "*/mouse?" , RUN+= "/usr/bin/xinput --set-prop 'SynPS/2 Synaptics TouchPad' 'Device Enabled' 1" |
And we have done!
Try to plug/unplug if it is behaving like expected!
In case of problems there is a way to debug udev events, in case the rules we defined do not apply exactly to your hardware configuration:
1 2 | sudo killall udevd sudo udevd --debug-trace --debug |
To restart udevd when you have finished the debug:
1 | /sbin/start_udev |
Useful link:
https://wiki.archlinux.org/index.php/Touchpad_Synaptics#Disable_touchpad_upon_external_mouse_detection
Thanks for the post. Worked perfectly first try!
ReplyDeleteWorks like a charm.. Thanks for sharing!
ReplyDeleteThanks a lot mate, this worked like a charm :)
ReplyDeleteWorked for me up to RHEL7/CentOS7
ReplyDeleteFor CentOS8, ENV{XAUTHORITY} has to be added and you may have to locate your Xauthority file as it
may no longer be in ~/.Xauthority
In my setup with lightdm it was under /run/lightdm/MYUSER/xauthority