Topic: How To: disable (Synaptics) touchpad when an USB mouse is connected
i never use my touchpad except for when i don't have my USB mouse connected. so it would make sense to have it disabled when i do.
i've read on the Arch-wiki that you can do this through udev, but i'm not quite confident enough to try that out yet, and then i stumbled across this simple solution, which i really like, because it is so simple. in fact, it is a bit of a hack, but it works.
this is for synaptics touchpads only, as the synclient is the synaptics touchpad driver. however, the concept stays the same for any other touchpad i guess.
make a bash-script somewhere (some place where you have your bash scripts). i called it 'touchoff.bash'.
gedit touchoff.bashGedit opens to an empty file. copy-paste in this code:
#!/bin/bash
# thank you: http://www.linuxquestions.org/questions/debian-26/shmconfig-in-debian-645503/#post3838794
# script to turn off touchpad if mouse present at login
# synclient is the synaptic utility to manage the touchpad
# grep the "lsusb" output and do a wordcount on number of lines with "Logitech" which should = 1 if a Logitech mouse is present
#
# Obviously the "Logitech" should be replaced with your brand of mouse, and perhaps be more exact in case you have other USB devices that have similar names
/usr/bin/synclient touchpadoff=`lsusb | grep Logitech | wc -l`save it.
now type:
chmod +x touchoff.bashthis makes it executable.
now, if you want to try how this works in the terminal (for better understanding, and to test if it actually works), type this:
synclient touchpadoff=1this should disable the touchpad (try it!) to enable it again, type:
synclient touchpadoff=0so now you have your own script for switching the touchpad on and off when a USB mouse is present. however, this is not nearly good enough. we want this stuff to happen automatically on start-up! so, let's add it to the Openbox autostart.sh file.
right-click somewhere to bring up the Openbox menu. go: Settings > Openbox Config > Edit autostart.sh
in the file, move somewhere to the bottom, so all the other stuff is loaded already before executing this command. now add the link to your script. for me, this is:
/usr/local/bin/scripts/touchoff.bash &for you it might be a different directory, so mind that stuff. also, do not forget the &. if you want to know why, read the autostart.sh documentation, google it.
try it out! logout, log back in, and see if it works!