The script below shows how to use xinput and sed to enable and disable the trackpad and, when the script is assigned to a shortcut key, it makes it quite handy. The script uses the sed pattern “s/(.+)(id=)(.+)[(.+)/\3/" to retrieve the correct trackpad ID.

Please note that you will need the following programs installed before the script will run:

  • sed
  • awk
  • xinput
  • dunst
$$ #!/usr/bin/env bash me=$(uname -a | awk '{print $2}') if [[ $me == 'void-linux' ]] || [[ $me == 'CHROMEBOOK' ]] || [[ $me == 'dell' ]]; then searcher='Touchpad' else searcher='bcm5974' fi myID=$(xinput list | grep $searcher | sed -E "s/(.+)(id=)(.+)\[(.+)/\3/") state=$(xinput list-props $myID | grep 'Device Enabled' | sed 's/^\(.\+\)Enabled.\+\(.\+\)$/\2/') if [[ ($state == '1') ]]; then xinput disable $myID dunstify "TrackPad is disabled" else xinput enable $myID dunstify "TrackPad is enabled" fi $$