How to disable touchpad using code - Mon, Sep 20, 2021
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