Skip to main content

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Asked
Viewed 2k times
6

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
    –  xji
    2018-10-17 12:56:18 +00:00
    Commented 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...
    RubberStamp
    –  RubberStamp
    2018-11-17 15:10:53 +00:00
    Commented 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
    –  Inigo
    2023-07-10 04:50:25 +00:00
    Commented Jul 10, 2023 at 4:50

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.