Disabling the touch-pad in Linux when using an external USB mouse on a laptop

Sometimes I use an external USB [wireless] mouse when doing things that are cumbersome to do with a touch-pad, like 3D modeling in CAD software [Sketchup]. At such times, I have to find a setting in the system and disable the touch-pad. It works well but, when I later login after the laptop goes to sleep or I unplug and replug the external mouse for whatever reason, those settings are forgotten. Its pretty easy to disable the touch-pad on the linux terminal:

synclient TouchpadOff=1

and re-enable:

synclient TouchpadOff=0

You can even create an alias to make the command shorter and easier to remember and type-in

sudo nano ~/.bash_aliases

and add the following line

alias touchpaddoff='synclient TouchpadOff=1'
alias touchpadon='synclient TouchpadOff=0'

or a toggle function


function touchpadToggle() {
declare -i STATE
STATE=`synclient -l | less | grep TouchpadOff`
if([[ $STATE -eq 1 ]]); then
    synclient TouchpadOff=0
    echo 'Touchpad on'
    synclient TouchpadOff=1
    echo 'Touchpad off'

But… would it not be nice to have the udev events for the USB mouse do this for me?

sudo nano /etc/udev/rules.d/99-mouse.rules

And add the following lines:

ACTION=="add", SUBSYSTEM=="input", KERNEL=="mouse[1-9]", ENV{DISPLAY}=":0.0", ENV{XAUTHORITY}="/home/username/.Xauthority", ENV{ID_CLASS}="mouse", RUN+="/usr/bin/synclient TouchpadOff=1"
ACTION=="remove", SUBSYSTEM=="input", KERNEL=="mouse[1-9]", ENV{DISPLAY}=":0.0",ENV{XAUTHORITY}="/home/username/.Xauthority", ENV{ID_CLASS}="mouse", RUN+="/usr/bin/synclient TouchpadOff=0"

Then restart udev

sudo service udev restart

Enjoy messing with udev events and your external mice šŸ˜› !!!

One response to “Disabling the touch-pad in Linux when using an external USB mouse on a laptop”

  1. Evans Shango

    touchpad not working on my Lenovo Ideapad 320 for all linux versions

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: