Toggle touchpad on Ubuntu 16.04

ubuntu_logo_81x81Laptops with larger touchpad area pose a serious problem with typing. While we explored a way to reduce the effective touchpad area, sometimes turning off the touchpad is a better solution. The 14.04 way of setting synclient TouchpadOff to 0 or 1 doesn’t work on 16.04. So here’s a fresh technique with a little bit of scripting.

List all your input devices.

$ xinput
⎡ Virtual core pointer                       	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ DELL Laser Mouse                        	id=10	[slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad              	id=12	[slave  pointer  (2)]
⎜   ↳ Sony Vaio Jogdial                       	id=8	[slave  pointer  (2)]
⎣ Virtual core keyboard                      	id=3	[master keyboard (2)]
    ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
    ↳ Video Bus                               	id=6	[slave  keyboard (3)]
    ↳ Sony Vaio Keys                          	id=7	[slave  keyboard (3)]
    ↳ Power Button                            	id=9	[slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard            	id=11	[slave  keyboard (3)]

The device of our interest is SynPS/2 Synaptics TouchPad. Note down the device ID (12 in this case).

Check the current status of the device.

$ xinput -list-props 12 | grep "Device Enabled"
Device Enabled (139):	1

Now, modify the following script as per the IDs you see:

#!/bin/bash
if xinput list-props 12 | grep "Device Enabled (139):.*1" >/dev/null
then
  xinput disable 12
  notify-send -u low -i mouse "Touchpad disabled"
else
  xinput enable 12
  notify-send -u low -i mouse "Touchpad enabled"
fi

This script will take care of toggling the touchpad for you and notify the status. Copy it somewhere in your $PATH. You can assign a keyboard shortcut to the script and toggle the touchpad state anytime you want.

One thought on “Toggle touchpad on Ubuntu 16.04”

Comment

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