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.

Advertisements

11 thoughts on “Disabling Macbook Pro Touchpad

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

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

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

      $ ./touchpad.sh
      

      because ./ in above command indicates you are running the command from current working directory. Better issue command

      $ touchpad.sh
      

      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.

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

      $ su -
      # /home/jae/bin/touchpad.sh
      

      or as simple user, but with root privleges (sudo) (Here prompt need not be #)

      $ sudo /home/jae/bin/touchpad.sh
      

      In order to find whether synaptics is installed or not
      (on Debian/Ubuntu)

      $ aptitude search synaptics
      p   gsynaptics                                                                                  - configuration tool for Synaptics touchpad driver of X server                                         
      p   libsynaptics-dev                                                                            - library to access the synaptics touch pad driver (development)                                       
      p   libsynaptics0                                                                               - library to access the synaptics touch pad driver (runtime)                                           
      p   xfree86-driver-synaptics                                                                    - dummy package to upgrade to X.Org new modular packages                                               
      v   xorg-driver-synaptics                                                                       -                                                                                                      
      i A xserver-xorg-input-synaptics                                                                - Synaptics TouchPad driver for X.Org/XFree86 server                                                   
      
      $ which synclient
      /usr/bin/synclient
      
      

      or on Fedora/Redhat

      $ rpm -qa | grep synaptics
      
  5. 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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s