Ubuntu: How to disable/enable/toggle touchpad in a Dell laptop


I am trying to tweak the touchpad on Ubuntu 16.04 but none of the usual methods seem to work. e.g.

synclient touchpadOff=1  

It still works!

$ xinput set-prop $DEVICE_ID "Device Enabled" 0  $ xinput list-props 15 |head -n2    Device 'SynPS/2 Synaptics TouchPad':      Device Enabled (168):   0  

...it still works!

I can disable it from the Settings app. but I want to be able to map this to a keyboard shortcut, so I'm looking for a command line solution.

Bonus points if you answer works in Gnome-Shell as well as Unity :-)

EDIT: output of xinput as requested in comment.

$ xinput  ⎡ Virtual core pointer                      id=2    [master pointer  (3)]  ⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]  ⎜   ↳ ELAN Touchscreen                          id=12   [slave  pointer  (2)]  ⎜   ↳ DLL06E4:01 06CB:7A13 Touchpad             id=13   [slave  pointer  (2)]  ⎜   ↳ SynPS/2 Synaptics TouchPad                id=15   [slave  pointer  (2)]  ⎣ Virtual core keyboard                     id=3    [master keyboard (2)]      ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]      ↳ Power Button                              id=6    [slave  keyboard (3)]      ↳ Video Bus                                 id=7    [slave  keyboard (3)]      ↳ Video Bus                                 id=8    [slave  keyboard (3)]      ↳ Power Button                              id=9    [slave  keyboard (3)]      ↳ Sleep Button                              id=10   [slave  keyboard (3)]      ↳ Integrated_Webcam_HD                      id=11   [slave  keyboard (3)]      ↳ AT Translated Set 2 keyboard              id=14   [slave  keyboard (3)]      ↳ Dell WMI hotkeys                          id=16   [slave  keyboard (3)]  

Nb. I have used 15 for $DEVICE_ID

EDIT - thanks to the answer below here's my toggle script

You can do it in a one liner, but this way you get a nice notification, too. I've attached this to a shortcut key and it works a charm. Thanks all.

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


You can switch the touchpad off with this command:

xinput disable 13  

Enable it back by

xinput enable 13  

The device is not controlled by psmouse. It is controlled by synaptics_i2c. And it is device 13.

You can also toggle it by name as you tried before, not to depend on the ID. But if you do not connect new input devices, the ID should stay.

See this answer for some details.

To remove a wrongly detected device you need to add i8042.nopnp kernel boot parameter.


Using gsettings

If you can change settings by gsettings, generally it is the preferred option. Since you can enable/disable touchpad from System Settings, and I am pretty sure System Settings does use gsettings, it looks like the method below should do the job, on your Dell as well.

Script to toggle the touchpad


#!/usr/bin/env python3  import subprocess    key = "org.gnome.settings-daemon.peripherals.touchpad" ;val = "touchpad-enabled"  curr = subprocess.check_output(["gsettings", "get", key, val]).decode("utf-8").strip()  newval = "false" if curr == "true" else "true"  subprocess.Popen(["gsettings", "set", key, val, newval])  


#!/usr/bin/env python3  import subprocess    key = "org.gnome.desktop.peripherals.touchpad" ;val = "send-events"  curr = subprocess.check_output(["gsettings", "get", key, val]).decode("utf-8").strip()  newval = "disabled" if curr == "'enabled'" else "enabled"  subprocess.Popen(["gsettings", "set", key, val, newval])  

To use it

  1. Copy the script above, for your correct Ubuntu version, into an empty file, save it as toggle_touchpad.py
  2. Add the following command to a shortcut:

    python3 /path/to/toggle_touchpad.py  

    Choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command:

    python3 /path/to/toggle_touchpad.py  


The command to disable touchpad:

for 14.04:

gsettings set org.gnome.settings-daemon.peripherals.touchpad touchpad-enabled false  

for 15.04 +:

gsettings set org.gnome.desktop.peripherals.touchpad send-events disabled  

Read the current state

If we use a script to read the current settings by the command:

gsettings get org.gnome.settings-daemon.peripherals.touchpad touchpad-enabled  

(14.04), or

gsettings get org.gnome.desktop.peripherals.touchpad send-events  


We can make the script set the opposite value, and thus toggle the touchpad.

EDIT; bash version of the toggle script

Just to be complete, and because OP indicated the python script(s) worked, but not wanted to use python, the bash version(s) of the two toggle scripts:


#!/bin/bash    key="org.gnome.settings-daemon.peripherals.touchpad"  val="touchpad-enabled" ;curr="$key $val"    if [ "$(gsettings get $curr)" == "false" ]  then   gsettings set $key $val true  else   gsettings set $key $val false  fi  


#!/bin/bash    key="org.gnome.desktop.peripherals.touchpad"  val="send-events" ;curr="$key $val"    if [ "$(gsettings get $curr)" == "'enabled'" ]  then   gsettings set $key $val disabled  else   gsettings set $key $val enabled  fi  

To put under a shortcut key

  • Save the script as toggle_touchpad.sh
  • put the following command under a custom shortcut:

    /bin/bash /path/to/toggle_touchpad.sh  


I'm on 16.04 too. I usually using a little script that I put on a keyboard shortcut. When I execute it turns my touchpad off... But few seconds after it turns on ...

The script:

    #!/bin/sh    STATUS=`synclient | grep TouchpadOff | awk '{ print $3}'`            if [ $STATUS != 1 ];          then                  synclient touchpadOff=1;          else                  synclient touchpadOff=2;          fi  exit 0  

I don't try to use it before I see your question ...

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »