Thursday, September 10, 2009

Disabling Macbook Pro Touchpad

We may want to disable Macbook Pro (or any other Laptop) Touchpad, such cases are:
(i) We have connected a USB mouse, so we do not want to use touchpad for now.
(ii) While typing, there is no use of touchpad, if touchpad is too sensitive, the cursor keeps on jumping due to slight touch of palm or finger.

I have written a script to disable/enable touchpad (which is using synaptics driver).





#!/bin/bash

## Disable touchpad if USB Mouse is attached

SYNAPTICS=`which synclient`

if [[ "$SYNAPTICS" == "" ]]
then
echo "$0: please install synaptics touchpad driver."
echo "Also make sure that 'Option \"SHMConfig\" \"on\"'"
echo " is added in Touchpad device Section in /etc/X11/xorg.conf"
exit
fi

USB_mouse_present=`grep -ic "usb.*mouse" /proc/bus/input/devices`
# if no USB Mouse; enable touchpad
if [ $USB_mouse_present -eq 0 ]
then
$SYNAPTICS TouchpadOff=0
else
$SYNAPTICS TouchpadOff=1
fi

# if any parameter [on|off] is given, override previous command
if [ $# -ge 1 ]
then
if [ "$1" = "on" ]
then
$SYNAPTICS TouchpadOff=0
else
$SYNAPTICS TouchpadOff=1
fi
fi

exit 0



Sample Run:
Turn on touchpad

$ ./touchpad.sh on

Turn off touchpad

$ ./touchpad.sh off

If we have plugged USB mouse, then just give following command

$ ./touchpad.sh

On removing USB mouse, give following, the touchpad will be enabled automatically. :)

$ ./touchpad.sh


PS: The configuration for synaptics driver can be referred from here or here.

7 comments:

Rainer said...

thank you a lot, you safed my day :-))

Dashie said...

Thanks for the post! Worked great!

mitesh.singh.jat said...

Thanks Rainer and Dashie for finding this script useful. :)

Anonymous said...

It worked perfectly fine. Awesome job.

Muddy Richard said...

thank you very much.

kikewaa said...

Thanks a lot! I can type without any worry now. Seems like we have a new hero!! ^_^

pheobe22 said...

Thanks meant for sharing this type of satisfying opinion, written piece is fastidious, that’s why I’ve read it completely. imac repair