Cuttlefish is one of those must have apps you can use to automate automatic reactions to things like running a script at WLAN/LAN connection,application startup/close, Bluetooth connections and usb connections.
Too bad it is only in the 12.04 repos, here is how to add it to 12.10 easily. Note you will need the JRE for it to run.
echo ' deb http://ppa.launchpad.net/noneed4anick/cuttlefish/ubuntu precise main ' | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get install cuttlefish
Have fun!