Solution - automatic
Thanks to Esamo and his work.
To add AUTO triggers for connecting mouse on startup:
Create the file: /etc/udev/rules.d/10-local.rules
Fill up with this content: (replace $USER with your user name)
ACTION=="add", SUBSYSTEM=="input", KERNEL=="mouse[0-9]", ENV{DISPLAY}=":0",ENV{XAUTHORITY}="/home/$USER/.Xauthority", ENV{ID_CLASS}="mouse", RUN+="/home/$USER/scripts/touchpad_switcher.sh false"
ACTION=="remove", SUBSYSTEM=="input", KERNEL=="mouse[0-9]", ENV{DISPLAY}=":0",ENV{XAUTHORITY}="/home/$USER/.Xauthority", ENV{ID_CLASS}="mouse", RUN+="/home/$USER/scripts/touchpad_switcher.sh true"
Example:
ACTION=="add", SUBSYSTEM=="input", KERNEL=="mouse[0-9]", ENV{DISPLAY}=":0",ENV{XAUTHORITY}="/home/dawid/.Xauthority", ENV{ID_CLASS}="mouse", RUN+="/home/dawid/scripts/touchpad_switcher.sh false"
ACTION=="remove", SUBSYSTEM=="input", KERNEL=="mouse[0-9]", ENV{DISPLAY}=":0",ENV{XAUTHORITY}="/home/dawid/.Xauthority", ENV{ID_CLASS}="mouse", RUN+="/home/dawid/scripts/touchpad_switcher.sh true"
Next place your script wherever you want. I placed it in ~/scripts
touchpad_switcher.sh
#!/bin/sh
enabled=$1
touchpad_id=$(xinput | grep -i "touchpad" | cut -f2 | cut -d '=' -f2);
if $enabled
then
xinput set-prop $touchpad_id "Device Enabled" 1 | notify-send "The touchpad is now enabled." ""
else
xinput set-prop $touchpad_id "Device Enabled" 0 | notify-send "Disabling the touchpad..." ""
fi
Remember to add execute permissions:
chmod +x touchpad_switcher.sh
Now simply reboot! ( merely restarting udev doesn't seem to work...)
Some other useful stuff:
Some info about udev rules
Example from ArchLinux
Simlar question