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.
Advertisements

Thank you Mitesh for this post.
I have been looking for this for a long time.
This is really helpful and easy to use.
Nice content indeed! i will visit as often as i can.
cheers
I don’t know If I said it already but …I’m so glad I found this site…Keep up the good work I read a lot of blogs on a daily basis and for the most part, people lack substance but, I just wanted to make a quick comment to say GREAT blog. Thanks, π
A definite great read..Tony Brown
Hi, I have a few questions about this script.
1. Which directory shoudl i save touchpad.sh in?
2. Do i need to be in su mode to run it?
I ran it from my home directory and got a “Can’t access shared memory area. SHConfig disabled?” error message.
I am very new to Linux so please forgive my ignorance.
Thanks.
Jae
Hi Jae,
1. You can put this script in any directory. Best is to keep it in ~/bin/ where ~/bin is in $PATH.
2. Yes you need to run this script as root user (either use sudo ~/bin/touchpad.sh or use root shell)
The error βCanβt access shared memory area. SHConfig disabled?β comes when shared memory for synaptics driver is disabled,
which can be enabled by writing following line
Option "SHMConfig" "on"in
section in /etc/X11/xorg.conf file.
Please refer to blog
https://miteshjlinuxtips.wordpress.com/2009/05/22/macbook-pro-touchpad-synaptics-configuration-in-xorg-conf/
Regards,
Mitesh
Hi Mitesh, I tried what you suggested.
I moved the touchpad.sh to /bin dir and also editted the xorg.conf file like you suggestedd and then ran ./touchpad.sh on from the root user mode but still I get the same error.
Can you suggest anything else? The touchpad is very annoying in Linux.
Thanks.
Jae
Hi Jae,
I am a bit confused that, if you have moved touchpad.sh to /bin, then how can you run that script by giving command
because ./ in above command indicates you are running the command from current working directory. Better issue command
After editing xorg.conf you have to restart xserver, for that you need to logout and login again.
PS: I hope that you have synaptics touchpad driver is installed.
Hi Mitesh, I thought all script files(sh) should be run in ./filename.sh syntax.
So I ran filenamd.sh from the /bin directory and I still get the same error.
Also, you said to run the script from root user mode but your prompt is a $. Root user prompt is a # is it not?
How can you find out if synaptics driver is installed or not? I could not quite follow your link regarding synatic driver config.
Thanks.
Jae
Hi Jae,
You can place the script in any directory (say, /home/jae/bin/), then you can this script either as root user
or as simple user, but with root privleges (sudo) (Here prompt need not be #)
In order to find whether synaptics is installed or not
(on Debian/Ubuntu)
or on Fedora/Redhat
Hi Mitesh, this time it worked. I did have the synaptics driver installed. But the command I issued was touchpad.sh off/on which I tried last week but i got that “Canβt access shared memory area. SHConfig disabled?β error. Today I didn’t get the error for some reason. The only thing i did was I disabled touchpad from the Mac OS and then booted to Debian which doesn’t make any sense at all.
Thanks for your help.
Jae
Hi Jae,
Most welcome! π
Regards,
Mitesh