@bytehowl
Here is a ‘recalculated’ version (skip to Edit2):
#!/bin/sh
journalctl -f -p 6 | awk '/idVendor=046d|disconnect/ { system ("ydotool key 530:1 530:0") }'
find a unique string in journal when your mouse is plugged in /switched on and disconnected by this command:
journalctl -f -p 6
The customized script may be autostarted.
Static query is below at Edit2
It seems a bit over-engineered.
Edit2
For me the RTFM is pretty valid.
/usr/include/linux/input-event-codes.h
So having configured ydotool we also have touchpad on (531) and off (532) keycodes. Let’s wipe down the ‘white-board’ and simplify the case.
I inserted 2 scripts into Autostart a login and a logout one
cat momp.sh
#!/bin/sh
# Check whether mouse is plugged-in and disable/enable touchpad
while :
do
lsusb | grep -q Mouse
MOUSE="$?"
if [ "$MOUSE" != "$PREM" ]; then
case $MOUSE in
0)
ydotool key 532:1 532:0
;;
1)
ydotool key 531:1 531:0
;;
esac
PREM="$MOUSE"
fi
sleep 5
done
and before logout:
cat mompend.sh
#!/bin/sh
pkill momp.sh