[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Configuring hotplugged input devices



Quoting David Wright (2019-11-25 16:29:07)
> My problem is knowing what to put in the script to make a keyboard 
> layout apply only to a specific keyboard. I connect two keyboards; one 
> is an old IBM M with British layout (PS/2), the other is a Logitech 
> K520 with US layout (wireless).
> 
> Currently the machine boots in GB mode with the PS/2, and I have kbdgb 
> and kbdus functions to switch back and forth when I use either 
> keyboard. (For just the odd character I use memory of the easier 
> transpositions (like @"), or the composition key.)
> 
> How do you make layout scripts so specific?

Keyboard keys are mapped in multiple layers.

I don't think you can apply high-level XKB mapping to a specific 
keyboard device (within same "seat" at least), but if usable to you to 
remap specific keys at a lower level so that they both fit into same 
high-level composition, then read /lib/udev/hwdb.d/60-keyboard.hwdb 
(there are instructive comments at the top) for how to do that.

Concretely I recently ran this command on my Teres-I laptop, as root:

  evtest --grab /dev/input/event3

I then hit the key attached at keyboard at input device "event3", 
noticing its MSC_SCAN value.

When done I pressed CTRL+c at another keyboard that the "event3" one.

Then I added file "/etc/hwdb.d/70-keyboard.hwdb" with this content:

###########################################################
# Olimex
###########################################################

# Teres-I
evdev:input:b0003v15BAp003C*
 KEYBOARD_KEY_70066=sleep                               # Fn+F1
 KEYBOARD_KEY_700f6=wlan                                # Fn+F2
 KEYBOARD_KEY_700c7=f21                                 # Fn+F3 touchpad toggle
 KEYBOARD_KEY_7006f=brightnessdown                      # Fn+F7
 KEYBOARD_KEY_70070=brightnessup                        # Fn+F8
 KEYBOARD_KEY_7006e=switchvideomode                     # Fn+F9

Finally I ran these commands, also as root:

  systemd-hwdb update
  udevadm trigger /dev/input/event3

Since then I can hit Fn+F1 to trigger sleep on my laptop.

...I still haven't solved how to wake it up again, though ;-)


 - Jonas

-- 
 * Jonas Smedegaard - idealist & Internet-arkitekt
 * Tlf.: +45 40843136  Website: http://dr.jones.dk/

 [x] quote me freely  [ ] ask before reusing  [ ] keep private

Attachment: signature.asc
Description: signature


Reply to: