Saul Salazar/How to disable touchpad using code

Created Mon, 20 Sep 2021 00:00:00 +0000
135 Words

Dear Linux user, does your touchpad annoys you? Maybe your laptop keyboard shortcuts dont work and you cant disable it. Anyway, take this bash script with you.

We will be using xinput to get device information from the touchpad, which in my case is a Synaptics Touchpad

Bash Script

#!/bin/bash

# script to toggle state of synaptics touchpad

tpid=`xinput list | grep SynPS | sed 's/.*id\=\([0-9]\+\).*/\1/g'`

declare -i status
status=`xinput list-props ${tpid} | grep Device\ Enabled | sed -e 's/.*\:[ \t]\+//g'`

if [ 0 -eq ${status} ] ; then
    xinput enable ${tpid}
else
    xinput disable ${tpid}
fi

This script is an edited version for my own laptop model, please double check the code before running the command on your computer / workstation.

Don’t forget to give execution permissions using chmod +x:

chmod +x your_script_filename.sh

References

SpongeBob Open Source GIF