How to disable touchpad when mouse is connected and how to rebind mouse buttons?

Okay, that finally did it, but there’s another problem…

My touchpad is listed as “ELAN0501:00 04F3:3060 Mouse”, so that script would create the mouse tmp file even if I just have my touchpad.

Also, where am I supposed to put that script so it gets run when devices are (dis)connected?