Applescript to run when iPhone connects/disconnects
Is this sort of what you're looking for?


  Usbmux
  
  ...usbmuxd then watches for iPhone connections via USB; when it detects an iPhone running in normal mode (as opposed to recovery mode), it will connect to it and then start relaying requests that it receives via /var/run/usbmuxd – this is to say, usbmuxd is the only thing that actually speaks USB to the iPhone.


http://theiphonewiki.com/wiki/Usbmux