Tuesday, February 24, 2009

Auto Disable Synaptic Touch in Ubuntu Hardy

In windows, my pentium M platform will automatically disable synaptic touchpad when I connect an external mouse. It prevent me from unintentionally sliding my touchpad while typing. It's very annoying when a mouse cursor moves from current typing position to other places. I found some solutions in the internet.

First, you can completely disable notebook's touchpad if you always use a mouse. Click at menu System-> Preference -> Mouse go to Touchpad tab and you will see the checkbox.

Second, which I prefer. Turn on SHMConfig in xorg.conf

gksudo gedit /etc/X11/xorg.conf

Then make the code look like this
Section "InputDevice"
Identifier "Synaptics Touchpad"
Driver "synaptics"
Option "SendCoreEvents" "true"
Option "Device" "/dev/psaux"
Option "Protocol" "auto-dev"
Option "HorizEdgeScroll" "0"
Option "SHMConfig" "on"

After enable SHMConfig, we need to add rules to udev.

gksudo gedit /etc/udev/rules.d/10-local.rules

This will open an empty file. Add the following code
ACTION=="add", SUBSYSTEM=="input", ID_CLASS="mouse", RUN+="/usr/bin/synclient touchpadoff=1"
ACTION=="remove", SUBSYSTEM=="input", ID_CLASS="mouse", RUN+="/usr/bin/synclient touchpadoff=0"

However, it doesn't work when Ubuntu start up. Udev's rules will be activated only when mouse is plugged in or removed. I search for solutions and think that I need to write my own script by checking if an external mouse is connected to disable touchpad through synclient. At first, I think about using python. Luckily, after searching for a while how python checks devices, I found this solution[2]. Instead of using python, you can easily create use unix script by using the following code
#!/bin/bash

/usr/bin/synclient TouchpadOff=`lsusb | grep Mouse | wc -l`

Where Mouse is your output from lsusb that matchs your external mouse. For me, it is Logitech.
then put it to System -> Preference -> Sessions
or init.d[3]
my disable touchpad script in System -> Preference -> Sessions

Lastly, you can disable touchpad while typing by using the following command.

syndaemon -i 1 -d

Resources:
[1] - http://ubuntuforums.org/showthread.php?t=724465
[2] - http://digitalgraphy.wordpress.com/2007/11/17/how-to-disable-touchpad-on-linux/
[3] - https://help.ubuntu.com/community/UbuntuBootupHowto

No comments: