Linux Mint – Disable Touchpad on Mouse Connect

Hello my dear readers,

I was struggling with the Touchpad in my laptop as it’s very sensitive and activates even with the softest touch.

Being a shell script enthusiast made me think that some simple, efficient code could for sure make this work. So I did some Googling and found some code that may come handy for this.

The original post by red-lichtie can be found on the LM forums by following this LINK

But for the sake of simplicity, let’s put the code here.

A script: /usr/local/bin/toggleTouchpad.sh (with perms 766 so that only root can call it)

#!/bin/sh
sleep 1
TOUCHPAD_NAME=touchpad
DISPLAY=":0.0"
XAUTHORITY=/var/lib/mdm/:0.Xauth
export DISPLAY XAUTHORITY
tpID=$(xinput list | grep -i $TOUCHPAD_NAME | awk '{ print $6 }' | sed 's/id=//')
case "$1" in
   on)
   /usr/bin/xinput --enable $tpID
   ;;
   off)
   /usr/bin/xinput --disable $tpID
   ;;
esac

And a rule set: /etc/udev/rules.d/99-touchpad-autotoggle.rules

SUBSYSTEM!="usb", GOTO="touchpad-autotoggle_end"
ACTION=="add",    ATTR{bInterfaceClass}="03", ATTR{bInterfaceSubClass}="01", ATTR{bInterfaceProtocol}="02", RUN+="/usr/local/bin/toggleTouchpad.sh off"
ACTION=="remove", ATTR{bInterfaceClass}="03", ATTR{bInterfaceSubClass}="01", ATTR{bInterfaceProtocol}="02", RUN+="/usr/local/bin/toggleTouchpad.sh on"
LABEL="touchpad-autotoggle_end"

These are some awesome 19 lines that solve a requirement that is well-known in the Linux community. Even more outstanding is the fact that while using the very core of the Linux functionalities as SH, udev and xinput; this functionality will work for any Linux distro that doesn’t come with this option already.

For me on Linux Mint

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s