EDIT: This is NOT a duplicate because the linked question is about external USB drives, not keyboards. The suggested command
udevadm info -a -n sdb does nothing in helping to find the corresponding attributes for the keyboard.
After spending more than an hour on this, eventually I tried the following, which is unlikely to be accurate:
SUBSYSTEMS="input", RUN+="/home/jx/Dropbox/scripts/keyboard.sh %p" SUBSYSTEMS="hid", RUN+="/home/jx/Dropbox/scripts/keyboard.sh %p" SUBSYSTEMS="usb", RUN+="/home/jx/Dropbox/scripts/keyboard.sh %p"
However, it only worked when I first start up the computer. Whenever I unplug the keyboard and reconnect it later, the script doesn't get executed automatically.
How can I find the attributes for the keyboard and how do I ensure the script gets every time the keyboard is connected, even when the OS is already running?
I'm performing two modifications on my keyboard on startup:
xset r rate 160 50 setxkbmap -option "ctrl:nocaps"
However, they seem to be lost whenever I disconnect my external USB keyboard (sometimes I switch the keyboard between machines), and I always have to re-execute the commands whenever I reconnect it, which is quite annoying.
Is there a way to let the system detect the keyboard connection event and execute a custom script upon it?
Or maybe, alternatively, find a way to keep those two settings permanent even after restart.
I am on Arch Linux with systemd.