I did something like this related with bluetooth, I used udev to detect the devices (which imho is the right layer) and it worked great with no false positives. What I did was: -Detect if any keyboard was present -Detect Mouse/touchpad you have a Qt wrapper of udev in kdelibs/solid. Cheerz.