24
Options:
ifplugd will run the script of your choice when a cable is plugged into or unplugged from your network interface.
If you are using Debian you can add a script to the subdirectories of /etc/network, where there are scripts that are run every time an interface goes up or down.
If neither of the above are suitable for your needs, look into D-Bus. I've never had much luck using it successfully, but this is the sort of thing it was designed for.