You are not logged in.

#1 2008-02-20 22:26:36

Bralkein
Member
Registered: 2004-10-26
Posts: 354

Problem disabling touchpad when mouse present

Hi,

I looked on the wiki to find out how to disable the touchpad on my laptop when a USB mouse is present. I configured xorg.conf in the correct way, then I added the following udev rules as instructed:

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"

This works to an extent, insofar as when I have a running system with X working the touchpad is disabled and enabled when the mouse is plugged in or removed respectively. However, when I boot the machine with a mouse attached, X starts up and both devices are enabled. The reason for this is twofold:

1. synclient will not work properly when the X server is not running
2. An "add" action is not generated for the device unless you actually plug it in on a running system

Is there any way to detect the presence of the USB mouse on boot and disable the touchpad? It would be much cooler if this could be done without looking for specific device names like /dev/input/mouse0, mouse1 etc. because then we will have a solution that works for everyone that we can put on the wiki.

Offline

#2 2008-02-20 22:37:16

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: Problem disabling touchpad when mouse present

OK, so this is just a skeleton of a possible solution...  Assuming that it is a USB mouse that we're talking about...  Run "lsusb and check the ID number of the mouse (it should look something like "07aa:2501", for example).  Write a little script which looks something like this:

#!/bin/sh
lsusb | grep -q 07aa:2501
if [ "$?" -eq "0" ]
then
/usr/bin/synclient TouchpadOff=1
fi

Change "07aa:2501" to the ID of your mouse, of course.  The script checks if the mouse is connected and if it is it disables the touchpad; if mouse is not connected then nothing happens.  I haven't checked if it works (I have no mouse to try it with here) but it should work.  Once you save the script and make it executable add it to /etc/rc.local so that it gets executed on every boot.

EDIT: You're right -- synclient is not going to work if X server is not running, so the rc.local is not a good place to execute that script...  It's not a huge problem -- you should be able to execute it during the start up routine of X (add it to xinitrc, possibly with sleep to make sure that X is actually started when the script is executed) or to autostart in gnome/kde (depending on what WM/DE you're using).

Last edited by fwojciec (2008-02-20 22:46:00)

Offline

#3 2008-02-21 00:23:00

Bralkein
Member
Registered: 2004-10-26
Posts: 354

Re: Problem disabling touchpad when mouse present

Yeah, the thought of doing something like that had occurred to me. Your suggestion works, but it's such a crappy hack! There really ought to be a nice way to do this...

Offline

Board footer

Powered by FluxBB