I have a problem. I often plug in an external German keyboard to my US laptop, which helps me work faster. I can do
xinput list and get the list and then do
setxkbmap -device to set layout as
de, but the problem is, depending on what else I have plugged in, the device number is not constant in every session. So every time I plug the keyboard in, or reboot my system, I have to do it again. I suppose I could write a shell script to fetch the name of the keyboard, and since I do not have another keyboard of same name, it would work, but I do not know how to accomplish this. Also, this script should not be called only at startup, but whenever an USB plug-n-play device is plugged in. I would be obliged to get some help.
Thanks in advance!