Device (dis)connected trigger

Is it possible to add a trigger that would activate when a USB or Bluetooth device is connected, such as a keyboard, headphones, dock station or monitor?