I've put together a little script that modifies my keyboard layout somewhat (using xmodmap). Until now, everything was fine, I just put that script into my startup programs (I'm using XFCE) and it automatically changed the configuration to my liking. Now, however, I've bought an external keyboard and as a consequence, if I (un)plug while the computer is already booted, the settings won't apply automatically, but I have to run the script manually.
Now I want to modify my script so that it will check whether or not a keyboard has been plugged and which would run the changes if that was indeed the case. The thing is, that in order for this to work, the script would have to constantly monitor whether or not the device is plugged in. So I'm guessing it would have to run as a daemon? Is there a way to do that?
I've looked around and I've seen a program called daemonize (http://software.clapper.org/daemonize/
). Would that be a good solution? Or should I manually insert a script (if that is possible at all) into the aprorpriate /etc subfolder that handles services that are run at boot?