Home

Setting a script to toggle a pointing device in Ubuntu Linux

I recently purchased a new laptop, and installed Ubuntu Linux. There’s one major problem with the laptop; the trackpad is too sensitive and resting your palm will click the mouse. The computer includes a shortuct (FN + F9) to disable the trackpad, but natrally from linux this doesn’t work.

Here’s how you can solve this:

  1. You need to get the name of the pointing device that you wish to disable, so open a terminal and type “xinput list”. (Note: if you have a second pointing device plugged in, unplug it before running this command to prevent confusion.)
    Example: The trackpad that I wish to disable is called “PS/2 Logitech Wheel Mouse”
  2. Create a new empty document someplace where you will remember the location (I recommend placing this in it’s own folder), and both you and whoever else that may use the script has write access to the containing directory. Name the document “togglemouse.sh”. (I like to put helpful scripts within a “scripts” folder in my home directory, but if you have a multi-user machine then you could put it in a shared drive or directory.)
  3. Open the new document with a text editor, and paste the following script.
    #!/bin/bash
    mouse="/tmp/mymouse"
    if [ -e $mouse ]; then
    xinput set-int-prop "PS/2 Logitech Wheel Mouse" "Device Enabled" 8 1
    rm /tmp/mymouse
    else
    xinput set-int-prop "PS/2 Logitech Wheel Mouse" "Device Enabled" 8 0
    echo 1 > /tmp/mymouse
    fi
  4. Change where it says “PS/2 Logitech Wheel Mouse”, to the name of the pointing device that you found in step 1. Then save.
  5. Now to disable the pointing device, you just need to run the script. The script will check the temp directory for a file called mymouse, if the file exists then it will enable the mouse and delete the file, if the file doesn’t exist then it will disable the mouse and create the file.
    • If you’re using Ubuntu, you can create a keyboard shortcut to run this script by going to
      System > Preferences > Keyboard Shortcuts
      Select “Add”, write a descriptive name for the shortcut, place the location of the script in the command, hit ok, click the right column next to the new shortcut and press the keys desired for your new shortcut.

EDIT: Moved the location of the mouse disabled file into the temp directory (/tmp/mymouse), so it goes away on reboot.


- Vi