How to disable touchpad using shortcut

I have already described how to disable touchpad when external mouse is connected using udev device manager, but today I want to share a simple shell script that I am using on Dell XPS 13 to disable/enable touchpad using single keyboard shortcut.

Ubuntu - Keyboard shortcuts
Ubuntu - Keyboard shortcuts

Use the following shell script to disable/enable touchpad depending on its current state.

# Shell script used to to disable/enable touchpad using single keyboard shortcut
# Source: 

# get device id
device_id="$(xinput list | sed  -ne '/DLL0665:01 06CB:76AD Touchpad/ s/.*id=\([0-9]*\).*/\1/p')"

if [ -n "${device_id}" ]; then
  # verify current state, set action
  check_state=$(xinput list ${device_id} --long | grep "This device is disabled")
  if [ -n "${check_state}" ]; then

  # execute action
  xinput ${action} ${device_id}

Define custom keyboard shortcut to switch touchpad back and forth.

Milosz Galazka's Picture

About Milosz Galazka

Milosz is a system administrator working for a successful Polish company and a long time supporter of Free Software Foundation and Debian operating system.

Gdansk, Poland