5

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.

3
  • Note that the "duplicate" question doesn't exactly solve my question since it's about external USB drives, but I couldn't easily find the attributes for my USB keyboard to match against. The page wiki.archlinux.org/index.php/… helps
    – xji
    Oct 17, 2018 at 12:56
  • You probably want to use the "Vendor:Device" attribute... similar to this ... lsusb should show the hexidecimal pair to use... and udevadm monitor -k should show you what changes each time you unplug the keyboard and plug it back in again... Nov 17, 2018 at 15:10
  • Greetings from July 2023. I have the exact same issue when re/connecting my Planck. Did you ever find any robust solution to this?
    – Inigo
    Jul 10 at 4:50

0

You must log in to answer this question.

Browse other questions tagged .