Since I have gotten my new laptop I have quickly become annoyed that when I plug in my external USB wireless mouse my synaptics touchpad is still active. The touchpad is fine when I am not using an external mouse, but I can’t stand tapping it while I am typing. So yesterday while making some jokes towards Cody Somerville and Martin Meredith on writing a program to fix it, they said a quick script could take care of it in the mean time. So what I did is wrote an elaborate, super hacker, elite bash script that starts with X. So you want to see it? Well, I can show you that and not have to kill you afterwards! Here it is:
mousecount=`grep mouse /proc/bus/input/devices |grep Handler |wc -l`
if [ “$mousecount” -eq “1” ]
then
synclient TouchpadOff=0
else
if [ “$mousecount” -gt “1” ]
then
synclient TouchpadOff=1
fi
fi
What this does is executes the grep command and assigns the output to $mousecount. The first “if” statement tests to see if only 1 mouse is active, in my case it would be the touchpad and no external mouse, so it will insure it doesn’t get deactivated. If that doesn’t test out, the next “if” statement will see if it is equal to 2, meaning I have more than 1 mouse attached, the 2nd being the external USB wireless mouse. If it sees 2 mice, then it will execute the “synclient TouchpadOff=1” command disabling the synaptics touchpad.
Pretty easy I think. Now if someone can come up with an even better way of doing this, please keep me informed. My little script is rather hackish, but it does what I want it to. I would love to see an application do this automatically when I plug or unplug my external mouse. Any takers ๐