Changes in hardware configuration are hardware based.
First of all, you cannot truly detect any hardware configuration through your scripting. You can probe for it, but the operating system kernel detects hardware changes like that. I would suggest probing /dev/usb for changes (or whatever your distro calls the usb device). Another thing to try is to execute an lsusb -v command, at the beginning and just pipe the output to grep for your search string. Python can execute system commands.
If you are, however, writing a device driver, write it in C first of all, and then you would want to take a look at the HAL API and the kernel source code.
|