Thanks, @Kasami for your super helpful answer here. I made a small change to include a desktop notification:
#!/usr/bin/env bash
IDFILE=~/tmp/touchpad_notification_id
[[ -f $IDFILE ]] && ID="-r $(<$IDFILE)" || ID=""
if [ $(gsettings get org.gnome.desktop.peripherals.touchpad send-events) == "'en
echo "Switching off"
gsettings set org.gnome.desktop.peripherals.touchpad send-events disabled
notify-send -pe $ID -a Touchpad "Touchpad disabled" > $IDFILE
else
echo "Switching on"
gsettings set org.gnome.desktop.peripherals.touchpad send-events enabled
notify-send -pe $ID -a Touchpad "Touchpad enabled" > $IDFILE
fi
The arguments (for those unfamiliar with notify-send):
-p - print the numeric id of the new notification
-e - transient notification - don't persist in unread notifications
-r - replace the previous notification if it exists (used in $ID)
-a - app name
The rest of the shell stuff just stores the notification ID in a temp file so the notification can be replaced the next time. This is useful if you press the shortcut key a few times and want to actually see it "toggle", vs the notifications being displayed one after the other only after they time out or you dismiss them.