Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm using ubuntu 14.04 installed in EFI Mode, I tried to write simple udev rule which for all external USB keyboards will map capslock for escape. I use a lot of vim and plug and unplug keyboards often so this will simplify things a lot. So following different tutorials I 've made such file

cat /etc/udev/hwdb.d/61-keyboard-local.hwdb


keyboard:usb:v*p*
keyboard:usb:v046dpc30e*
    KEYBOARD_KEY_58=esc

then I executed

udevadm hwdb --update

but it doesn't work. I've used doubled mapping first general rule for any USB keyboard

keyboard:usb:v*p*

and for the one that I had already plugged

keyboard:usb:v046dpc30e*

thought maybe specific work will work but unfortunatelly not.

so I tried to debug what is wrong and following other tutorial run this:

udevadm --debug test /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/0003:046D:C30E.0007/input/input20
calling: test
version 204 
This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.

=== trie on-disk === 
tool version:          204 
file size:         5740456 bytes
header size             80 bytes
strings            1262416 bytes
nodes              4477960 bytes
load module index
read rules file: /lib/udev/rules.d/40-crda.rules
read rules file: /lib/udev/rules.d/40-gnupg.rules
read rules file: /lib/udev/rules.d/40-gnupg2.rules
read rules file: /lib/udev/rules.d/40-hyperv-hotadd.rules
read rules file: /lib/udev/rules.d/40-inputattach.rules
read rules file: /lib/udev/rules.d/40-libgphoto2-6.rules
GOTO 'libgphoto2_usb_end' has no matching label in: '/lib/udev/rules.d/40-libgphoto2-6.rules'
read rules file: /lib/udev/rules.d/40-libsane.rules
read rules file: /lib/udev/rules.d/40-usb-media-players.rules
read rules file: /lib/udev/rules.d/40-usb_modeswitch.rules
read rules file: /lib/udev/rules.d/42-usb-hid-pm.rules
read rules file: /lib/udev/rules.d/50-firmware.rules
read rules file: /lib/udev/rules.d/50-udev-default.rules
read rules file: /lib/udev/rules.d/55-dm.rules
read rules file: /lib/udev/rules.d/56-hpmud.rules
read rules file: /lib/udev/rules.d/60-cdrom_id.rules
read rules file: /lib/udev/rules.d/60-keyboard.rules
read rules file: /lib/udev/rules.d/60-pcmcia.rules
read rules file: /lib/udev/rules.d/60-persistent-alsa.rules
read rules file: /lib/udev/rules.d/60-persistent-input.rules
read rules file: /lib/udev/rules.d/60-persistent-serial.rules
read rules file: /lib/udev/rules.d/60-persistent-storage-dm.rules
read rules file: /lib/udev/rules.d/60-persistent-storage-tape.rules
read rules file: /lib/udev/rules.d/60-persistent-storage.rules
read rules file: /lib/udev/rules.d/60-persistent-v4l.rules
read rules file: /lib/udev/rules.d/61-accelerometer.rules
read rules file: /lib/udev/rules.d/64-btrfs.rules
read rules file: /lib/udev/rules.d/64-xorg-xkb.rules
read rules file: /lib/udev/rules.d/66-xorg-synaptics-quirks.rules
read rules file: /lib/udev/rules.d/69-cd-sensors.rules
IMPORT found builtin 'usb_id --export %p', replacing /lib/udev/rules.d/69-cd-sensors.rules:89
read rules file: /lib/udev/rules.d/69-libmtp.rules
read rules file: /lib/udev/rules.d/69-xorg-vmmouse.rules
read rules file: /lib/udev/rules.d/69-xserver-xorg-input-wacom.rules
read rules file: /etc/udev/rules.d/70-persistent-net.rules
read rules file: /lib/udev/rules.d/70-power-switch.rules
read rules file: /lib/udev/rules.d/70-printers.rules
read rules file: /lib/udev/rules.d/70-uaccess.rules
read rules file: /lib/udev/rules.d/71-seat.rules
read rules file: /lib/udev/rules.d/73-idrac.rules
read rules file: /lib/udev/rules.d/73-seat-late.rules
read rules file: /lib/udev/rules.d/75-net-description.rules
read rules file: /lib/udev/rules.d/75-persistent-net-generator.rules
read rules file: /lib/udev/rules.d/75-probe_mtd.rules
read rules file: /lib/udev/rules.d/75-tty-description.rules
read rules file: /lib/udev/rules.d/77-mm-ericsson-mbm.rules
read rules file: /lib/udev/rules.d/77-mm-huawei-net-port-types.rules
read rules file: /lib/udev/rules.d/77-mm-longcheer-port-types.rules
read rules file: /lib/udev/rules.d/77-mm-nokia-port-types.rules
read rules file: /lib/udev/rules.d/77-mm-pcmcia-device-blacklist.rules
read rules file: /lib/udev/rules.d/77-mm-platform-serial-whitelist.rules
read rules file: /lib/udev/rules.d/77-mm-qdl-device-blacklist.rules
read rules file: /lib/udev/rules.d/77-mm-simtech-port-types.rules
read rules file: /lib/udev/rules.d/77-mm-usb-device-blacklist.rules
read rules file: /lib/udev/rules.d/77-mm-usb-serial-adapters-greylist.rules
read rules file: /lib/udev/rules.d/77-mm-x22x-port-types.rules
read rules file: /lib/udev/rules.d/77-mm-zte-port-types.rules
read rules file: /lib/udev/rules.d/77-nm-olpc-mesh.rules
read rules file: /lib/udev/rules.d/78-graphics-card.rules
read rules file: /lib/udev/rules.d/78-sound-card.rules
read rules file: /lib/udev/rules.d/80-drivers.rules
read rules file: /lib/udev/rules.d/80-mm-candidate.rules
read rules file: /lib/udev/rules.d/80-udisks2.rules
read rules file: /lib/udev/rules.d/85-brltty.rules
read rules file: /lib/udev/rules.d/85-hdparm.rules
read rules file: /lib/udev/rules.d/85-hplj10xx.rules
read rules file: /lib/udev/rules.d/85-keyboard-configuration.rules
read rules file: /lib/udev/rules.d/85-regulatory.rules
read rules file: /lib/udev/rules.d/85-usbmuxd.rules
read rules file: /lib/udev/rules.d/90-alsa-restore.rules
read rules file: /lib/udev/rules.d/90-alsa-ucm.rules
read rules file: /lib/udev/rules.d/90-libgpod.rules
read rules file: /lib/udev/rules.d/90-pulseaudio.rules
read rules file: /lib/udev/rules.d/95-cd-devices.rules
read rules file: /lib/udev/rules.d/95-udev-late.rules
read rules file: /lib/udev/rules.d/95-upower-battery-recall-dell.rules
read rules file: /lib/udev/rules.d/95-upower-battery-recall-fujitsu.rules
read rules file: /lib/udev/rules.d/95-upower-battery-recall-gateway.rules
read rules file: /lib/udev/rules.d/95-upower-battery-recall-ibm.rules
read rules file: /lib/udev/rules.d/95-upower-battery-recall-lenovo.rules
read rules file: /lib/udev/rules.d/95-upower-battery-recall-toshiba.rules
read rules file: /lib/udev/rules.d/95-upower-csr.rules
read rules file: /lib/udev/rules.d/95-upower-hid.rules
read rules file: /lib/udev/rules.d/95-upower-wup.rules
read rules file: /lib/udev/rules.d/97-bluetooth-hid2hci.rules
rules contain 196608 bytes tokens (16384 * 12 bytes), 33727 bytes strings
18818 strings (164973 bytes), 15727 de-duplicated (134338 bytes), 3092 trie nodes used
device 0x15f81b0 has devpath '/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/0003:046D:C30E.0007/input/input20'
device 0x1600050 filled with db file data
device 0x15ff420 has devpath '/devices/virtual/dmi/id'
value '[dmi/id]sys_vendor' is 'Hewlett-Packard'
IMPORT builtin 'usb_id' /lib/udev/rules.d/40-libgphoto2-6.rules:3
device 0x15ff420 has devpath '/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/0003:046D:C30E.0007'
device 0x1605e30 has devpath '/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0'
/sys/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0: if_class 3 protocol 0
device 0x1607b80 has devpath '/devices/pci0000:00/0000:00:14.0/usb3/3-2'
device 0x1608170 has devpath '/devices/pci0000:00/0000:00:14.0/usb3'
device 0x1608550 has devpath '/devices/pci0000:00/0000:00:14.0'
device 0x1608930 has devpath '/devices/pci0000:00'
IMPORT builtin 'input_id' /lib/udev/rules.d/50-udev-default.rules:10
capabilities/ev raw kernel attribute: 120013
capabilities/abs raw kernel attribute: 0
capabilities/rel raw kernel attribute: 0
capabilities/key raw kernel attribute: 1000000000007 ff800000000007ff febeffdff3cfffff fffffffffffffffe
test_key: checking bit block 0 for any keys; found=1
test_key: checking bit block 64 for any keys; found=1
test_key: checking bit block 128 for any keys; found=1
test_key: checking bit block 192 for any keys; found=1
IMPORT builtin 'hwdb' /lib/udev/rules.d/50-udev-default.rules:11
IMPORT builtin 'hwdb' returned non-zero
IMPORT builtin 'path_id' /lib/udev/rules.d/60-persistent-input.rules:31
device 0x15ff420 filled with db file data
RUN 'kmod load $env{MODALIAS}' /lib/udev/rules.d/80-drivers.rules:5
unable to create temporary db file '/run/udev/data/+input:input20.tmp': Permission denied
.INPUT_CLASS=kbd
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/0003:046D:C30E.0007/input/input20
EV=120013
ID_BUS=usb
ID_FOR_SEAT=input-pci-0000_00_14_0-usb-0_2_1_0
ID_INPUT=1
ID_INPUT_KEY=1
ID_INPUT_KEYBOARD=1
ID_MODEL=HID_compliant_keyboard
ID_MODEL_ENC=HID\x20compliant\x20keyboard
ID_MODEL_ID=c30e
ID_PATH=pci-0000:00:14.0-usb-0:2:1.0
ID_PATH_TAG=pci-0000_00_14_0-usb-0_2_1_0
ID_REVISION=0180
ID_SERIAL=Logitech_HID_compliant_keyboard
ID_TYPE=hid
ID_USB_DRIVER=usbhid
ID_USB_INTERFACES=:030101:030000:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=Logitech
ID_VENDOR_ENC=Logitech
ID_VENDOR_ID=046d
KEY=1000000000007 ff800000000007ff febeffdff3cfffff fffffffffffffffe
LED=7
MODALIAS=input:b0003v046DpC30Ee0110-e0,1,4,11,14,k71,72,73,74,75,77,79,7A,7B,7C,7D,7E,7F,80,81,82,83,84,85,86,87,88,89,8A,B7,B8,B9,BA,BB,BC,BD,BE,BF,C0,C1,C2,F0,ram4,l0,1,2,sfw
MSC=10
NAME="Logitech HID compliant keyboard"
PHYS="usb-0000:00:14.0-2/input0"
PRODUCT=3/46d/c30e/110
PROP=0
SUBSYSTEM=input
TAGS=:seat:
UDEV_LOG=7
UNIQ=""
USEC_INITIALIZED=3550400
run: 'kmod load input:b0003v046DpC30Ee0110-e0,1,4,11,14,k71,72,73,74,75,77,79,7A,7B,7C,7D,7E,7F,80,81,82,83,84,85,86,87,88,89,8A,B7,B8,B9,BA,BB,BC,BD,BE,BF,C0,C1,C2,F0,ram4,l0,1,2,sfw'
unload module index

Any idea how can I debug it and make it work?

share|improve this question

1 Answer 1

The format is KEYBOARD_KEY_<hex scan code>. Use 'evtest' to find the correct scan code. Run it, select the appropriate device and press the key you want the scan code for. Look for something like:

Event: time 1410505361.975680, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70039
Event: time 1410505361.975680, type 1 (EV_KEY), code 58 (KEY_CAPSLOCK), value 1

You want the code located after MSC_SCAN, so on my keyboard it is 70039, I believe this is true for all USB-keyboards.

Also, after:

udevadm hwdb --update

you need:

udevadm trigger

To activate the new mapping.

share|improve this answer
    
It is true for my USB keyboard too. I had to reboot(!) to activate the new mapping though. –  Harm Oct 28 at 1:11
    
Did you run the two udevadm commands I mentioned? –  megahallon Oct 29 at 14:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.