Fred, I tried several scripts that just did not work. Then, this morning, I searched the forum and found this post -
Unfortunately, he posted in screenshots. I took the liberty of transcribing the touchpadonoff script. It works but I suppose that a function key switch is really a lot easier.
#!/bin/bash
# TouchOnOff, version 1.0, December 2017, Author: GFP
# Adaptation of the KbOnOff bash script
Icon=/usr/share/icons/gnome/256x256/status/user-available.png # <path to the touchpad icon on>
Icoff=/usr/share/icons/gnome/256x256/status/user-busy.png # <path to the touchpad icon off>
# because the value of "id" can change on xinput, the code does not rely on hardcoded id/master numbers
mainkey=`xinput list | grep "AlpsPS/2 ALPS DualPoint TouchPad"` # find your touchpad by using xinput
# above works if touchpad is enabled: "↳ AlpsPS/2 ALPS DualPoint TouchPad id=xx [slave pointer (y)]", or
# disabled: "∼ AlpsPS/2 ALPS DualPoint TouchPad id=xx [floating slave]"
idvar=`echo ${mainkey#*=}` # return "xx [slave pointer (y)]" or "xx [floating slave]" where xx=id number
idvar=`echo ${idvar%% *}` # return xx
#
touchvar=`echo ${mainkey#*[}` # return "slave pointer (y)]" or "floating slave]"
touchvar=`echo ${touchvar%% *}` # return "slave" or "floating"
if [ $touchvar = "floating" ] # touchpad currently disabled
then
mastkey=`xinput list | grep "Virtual core pointer"` # grab the master pointing string
# return "[ Virtual core pointer id=x [master pointer (y)]]"
mastkey=`echo ${mastkey#*"pointer ("}` # return "y)]"
mastkey=`echo ${mastkey%)*}` # return "y"
mastkey=$[$mastkey-1] # "y"-1 is the laptop touchpad master id
notify-send -i $Icon "Enabling touchpad..." \ "ON - Touchpad connected !"
echo "Enabling touchpad ..."
xinput reattach $idvar $mastkey
elif [ $touchvar = "slave" ] # touchpad currently enabled
then
notify-send -i $Icoff "Disabling Touchpad" \ "OFF - Touchpad disconnected"
echo "Disabling touchpad ..."
xinput float $idvar
fi
This is a handy script. Thanks @guillef.