I have already described how to disable the touchpad when an external mouse is connected using the udev device manager, but today I want to share a simple shell script that I am using on Dell XPS 13 to disable/enable the touchpad using a single keyboard shortcut.
Use the following shell script to disable/enable the touchpad, depending on its current state.
#!/bin/sh # Shell script used to to disable/enable touchpad using single keyboard shortcut # Source: https://sleeplessbeastie.eu/2016/07/11/how-to-disable-touchpad-using-shortcut/ # 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 action="enable" else action="disable" fi # execute action xinput ${action} ${device_id} fi
Define custom keyboard shortcut to switch touchpad back and forth.