Script to Detect Mouse and Turn On/Off Trackpad#!/usr/bin/env bash
## Get the touchpad id. The -P means perl regular expressions (for \K)
## the -i makes it case insensitive (better portability) and the -o
## means print only the matched portion. The \K discards anything matched
## before it so this command will print the numeric id only.
TID=$(xinput list | grep -iPo 'touchpad.*id=\K\d+')
## Run every second
while :
do
## Disable the touchpad if there is a mouse connected
## and enable it if there is none.
xinput list | grep -iq mouse && xinput disable "$TID" || xinput enable "$T$
## wait one second to avoid spamming your CPU
sleep 1
done

Thank you so much for the generous donation of a round sponsorship, in support of our sixth annual Trivia Night. It was a huge success thanks to the great businesses in our neighborhood, like yours...We appreciate your cooperation and support for your neighborhood.