Comments on How To Auto-Disable The Touchpad When The Mouse Is Plugged In (Fedora 13)
How To Auto-Disable The Touchpad When The Mouse Is Plugged In (Fedora 13) Hello all, hopefully this brief how-to will help others, this issue has been bugging me for years. I want the same capability in Fedora that exists in most recent versions of Windows -- disable the touchpad on my laptop if an external mouse is plugged in. Note that my how-to is a little hardware-specific regarding the actual disabling of the touchpad; I'll discuss that more at the end of the guide.
18 Comment(s)
Comments
Update: I edited the scripts above to reflect a better way of using the xinput utility. Previously, I was recommending a command like the following to disable the touchpad:
xinput --set-int-prop 13 119 8 0
This works ... as long as the X server doesn't reorder devices. I discovered the vulnerability when my keyboard stopped working whenever my external mouse was plugged in (!). This was because I had rebooted, and this time the X server gave my keyboard an ID of '13', and the touchpad was now ID '14'. So, my scripts were enabling and disabling the keyboard whenever the mouse was plugged in ... not what I wanted. The edits above now show a more reliable way to enable and disable the touchpad:
to disable touchpad: xinput --set-prop "PS/2 Generic Mouse" "Device Enabled" 0
to enable touchpad: xinput --set-prop "PS/2 Generic Mouse" "Device Enabled" 1
Not only is this more reliable, but it is much easier to understand what xinput is doing (and also avoids the deprecated '--set-prop-int' xinput parameter).
So, an important improvement, please revisit your scripts if you were using my first xinput approach.
Ah, good, glad to hear it works on Ubuntu, too. Unfortunately, I don't have the time to fully test this on Ubuntu ... I would expect that it is mostly the same, but there is always the chance that the directory for the resume script is different on different distributions, or that the numbering of the name of the udev rules file might need to change on another distribution. As a matter of fact, both of those elements could change from release to release in the same distribution (and I haven't tested these scripts on Fedora 14 yet).
So, caveat emptor. I hope it does work great on Ubuntu ... but so far it has only been thoroughly tested on Fedora 13. Maybe people using this method can leave comments like "Works on Ubuntu 10.10" if they discover that it works for them.
Well, I have to say...
Works on Ubuntu 10.04! (not yet switched to 10.10 though)
Excellent tutorial. Many, many thanks!
xinput list
xinput --set-prop SynPS/2\ Synaptics\ TouchPad Device\ Enabled 0
Good tip ... of course, it is already mentioned as the second command in the author's how-to, above ...
Using quotes around the name of the device was not working for me for some reason. In Ubuntu 10.10 I had to:
sudo apt-get install xinput
xinput list
xinput list-props ImPS/2\ ALPS\ GlidePoint\
DISABLE TOUCH PAD:
xinput --set-prop ImPS/2\ ALPS\ GlidePoint "Device Enabled" 0
ENABLE TOUCH PAD:
xinput --set-prop ImPS/2\ ALPS\ GlidePoint "Device Enabled" 1
Now if I can map those two scripts to a button on my keyboard I will be happy. Can linux commands have an IF statement? If so,(no pun intended) anyone have an idea of what I could do to check if the mouse is disabled or enabled? Maybe something like:
If
xinput --set-prop ImPS/2\ ALPS\ GlidePoint "Device Enabled" 1 =true
xinput --set-prop ImPS/2\ ALPS\ GlidePoint "Device Enabled" 0
else
xinput --set-prop ImPS/2\ ALPS\ GlidePoint "Device Enabled" 1
I would expect you could get your conditional logic using the CASE statement seen in the 99touchpad example.
this tip is most useful on my small netbook while i type.
If you're running Gnome (on Fedora 14)
1. System->Preferences->Mouse
2. Go to Touchpad tab
3. Select ' Disable touchpad while typing'
Debian Squeeze running on an older Macbook. Strangely, when I type "xinput --set-prop appletouch Device\ Enabled 1" (or 0), the appletouch enables and disables. However, when I put the exact same command in 61_touchpad.rules, it doesn't work.
I've verified that the rules are being run, and that what is called from the script is the same as what I type (with the exception of the back slash). But it doesn't work.
I suspect the problem is the "Macintosh-ness" of the computer, rather than your scripts and that this would work on a "normal" laptop. I'll come back if I figure it out.
For now I simply disable it by hand from a command prompt. I set couple of aliases that take the pain out. Which is not as nice, but better than nothing...
I have the same issue on a Dell laptop with Ubuntu 11.04
This works nicely in Ubuntu, too. ximput is already installed by default, so Ubuntu users can just go ahead with the rest of the tutorial. Better yet, why not make this howto generic?
It works also for me on Ubuntu 10.10 but I added /etc/pm/sleep.d/touchpad99 to the /etc/pm/power.d directory too, otherwise when AC cable is not connected touchpad is disabled.
Your HowTo works well also on my Sony Vaio VPCF1 with Ubuntu 10.10 but with one addition: on my laptop /etc/pm/sleep.d/99touchpad has to be copied to /etc/pm/power.d/99touchpad, otherwise when AC cable is not connected touchpad is no available.
Filippo.
also need to launch the xhost application (requires /root/.Xauthority to exist...can be a sym link to your primary user directory file)
to turn off is now:
sh -c 'export DISPLAY=:0; export PROTOCOL=auto-dev; export XAUTHORITY=/root/.Xauthority; /usr/bin/xhost +localhost; /usr/bin/xinput --set-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 0' >>/var/log/synoff 2>>/var/log/synoff
also need to launch the xhost application (requires /root/.Xauthority to exist...can be a sym link to your primary user directory file)
to turn off is now:
sh -c 'export DISPLAY=:0; export PROTOCOL=auto-dev; export XAUTHORITY=/root/.Xauthority; /usr/bin/xhost +localhost; /usr/bin/xinput --set-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 0' >>/var/log/synoff 2>>/var/log/synoff
It also looks like the weblink was stripped from my previous posting. Full scripts can be found here:
http://www.evga.com/forums/tm.aspx?high=&m=1755212
(see the weblink for full scripts for Ubuntu 12)
The lines/shell calls that start with DISPLAY=:0 do not incorporate this value of DISPLAY. Those statements must be set off from the following commands by ; or && or the variable will not be set. To test: type "DISPLAY=:99 echo hi $DISPLAY" at the command line)
The other major change I had to make was in conjunction with the .rules files - for some reason an external USB keyboard registers in my system as being mouse0, despite not having ID_INPUT_MOUSE set.
case "$1" in
thaw|resume)
tc=0
for i in `ls -d /dev/input/mouse*`; do
if [ `udevadm info --query=property --name=$i | egrep -c "ID_INPUT_(TOUCHPAD|MOUSE)"` -ge 1 ]; then
#some are entered as both a touchpad AND a mouse, each device can only add one to the total number of mice. Could alternately check if any mouse is plugged in that is NOT a touchpad. This counting is needed in general because I have an external USB keyboard that registers as "mouse0", but does not match either MOUSE or TOUCHPAD above.
(( tc += 1 ))
fi
done
if [ $tc -gt 1 ]; then
disable_touchpad
else
enable_touchpad
fi
;;
*) exit $NA
;;
esac