Automatically disable touchpad when usb mouse is attached

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Please don't add support questions to tutorials,start your own thread in the appropriate sub-forum instead. Before you post please read this
red-lichtie
Level 1
Level 1
Posts: 10
Joined: Sun Jul 07, 2013 3:41 pm

Automatically disable touchpad when usb mouse is attached

Postby red-lichtie » Thu Jun 12, 2014 5:54 pm

Just a quick way to implement this on LM using udev

Use the MDM standard .Xauth to toggle the for local user (the one attacing the mouse).

/usr/local/bin/toggleTouchpad.sh

Code: Select all

#!/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


chmod 766 /usr/local/bin/toggleTouchpad.sh
(so that only root (udev) can call it)

Basically plugging in any mouse class device disables the touchpad.

/etc/udev/rules.d/99-touchpad-autotoggle.rules

Code: Select all

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"



Enjoy :D

pxbacher
Level 1
Level 1
Posts: 2
Joined: Sun Jan 02, 2011 4:13 pm

Re: Automatically disable touchpad when usb mouse is attache

Postby pxbacher » Thu Aug 14, 2014 9:39 am

Thanks! Works great (so far)!

Mirlan
Level 1
Level 1
Posts: 4
Joined: Wed Sep 28, 2016 11:02 am

Re: Automatically disable touchpad when usb mouse is attached

Postby Mirlan » Wed Sep 28, 2016 11:07 am

Thanks! Works great on Linux Mint 17.3 Rosa.


Return to “Tutorials”