You are not logged in.
hi, I had posted this topic in the [ newbie corner ] subforum for days, but got no repliy. I hope I can find luck here.
I'm trying to use udev hwdb for swapping pairs of keys ( esc, caps_lock ) and ( rightAlt , rightCtrl ) . I followed the instruction here Map Scancodes to Keycodes with procedures describe blow. I only succeed in exchanging pair (esc, caps_lock) but failed in (rightAlt, rightCtrl).
Details of Procedures:
Create an empty file under /usr/lib64/udev/hwdb.d with file name 90-custom-keys.hwdb . Add the following lines into this file.
keyboard:dmi:bvn*:bvr*:bd*:svnDell*:pn*
KEYBOARD_KEY_01=capslock
KEYBOARD_KEY_3a=esc
KEYBOARD_KEY_e038=rightctrl
KEYBOARD_KEY_e01d=rightalt
Rebuilding hwdb.bin
udevadm hwdb --update
Testing and reboot my system
udevadm --debug test /devices/platform/i8042/serio0/input/input0/event0
udevadm --debug test-builtin keyboard /devices/platform/i8042/serio0/input/input0/event0
Parts of the testing result of the last command looks like
device 0x1ce3890 has devpath '/devices/platform/i8042/serio0/input/input0/event0'
device 0x1ce3890 filled with db file data
keyboard: mapping scan code 1 (0x1) to key code 58 (0x3a)
keyboard: mapping scan code 58 (0x3a) to key code 1 (0x1)
keyboard: mapping scan code 129 (0x81) to key code 164 (0xa4)
keyboard: mapping scan code 130 (0x82) to key code 166 (0xa6)
......
keyboard: mapping scan code 164 (0xa4) to key code 166 (0xa6)
keyboard: mapping scan code 216 (0xd8) to key code 152 (0x98)
keyboard: mapping scan code 217 (0xd9) to key code 191 (0xbf)
keyboard: mapping scan code 57373 (0xe01d) to key code 100 (0x64)
Error calling EVIOCSKEYCODE: Invalid argument
keyboard: mapping scan code 57400 (0xe038) to key code 97 (0x61)
Error calling EVIOCSKEYCODE: Invalid argument
keyboard: mapping scan code 237 (0xed) to key code 226 (0xe2)
unload module index
Thie last 6 lines seems to be complaining the problem, saying that 0xe038 and 0xe01d are invalid scancodes.
But they are scancodes of rightAlt and rightCtrl respectively, which I got from
showkey -s
After rebooting the system with the above settings, esc works as caps_lock and caps_lock works as esc but rightAlt and rightCtrl has no changes.
Last edited by kejingzhang (2013-10-10 02:32:29)
Offline
try xmodmap, I have a file .Xmodmap in my ~:
remove Lock = Caps_Lock
keysym Caps_Lock = Super_L
keysym Menu = Super_L
keycode 94 = Multi_key
This makes Caps and Menu keys act as Super (Windows key), and a extra key on my keyboard as the compose key. I posted it because you can see how to use keycodes to map keys(use xev to catch the keycodes(Right Alt is 108 on my laptop)). Then put 'xmodmap .Xmodmap' in your bashrc, or some file that is automatically run(I have it in .i3/config)
Offline
setxkbmap can be more reliable than xmodmap (at least when you run it during X session startup, like in xinitrc) and it has options for many common changes to modifier keys. See
/usr/share/X11/xkb/rules/base.lst
for a list with short descriptions. It's a long list, so search for swapescape and ralt to get to relevant options.
Edit: I don't know about the invalid argument error, but I just want to point out that you're not supposed to put custom configs under /usr/lib; they belong in /etc/udev/hwdb.d/.
Last edited by Raynman (2013-10-07 10:56:42)
Offline
setxkbmap can be more reliable than xmodmap (at least when you run it during X session startup, like in xinitrc)
I know it's a bit offtopic, but can you please elaborate a bit. I have never had any issues with xmodmap.
Offline
Thanks plam and Raynman for your help . Follow your hints, I succeed the swapping key task in an alternative method.
Using the command 'setkeycodes' and adding these commands into a systemd controlled service script, keymaps are exchanged as gdm started.
Here is my script and steps for doing this.
Created a file with filename custom-keys.service under /etc/systemd/system. Add the following context to the file.
[Unit]
Description=Keymap Custom
Requires=gdm.service
After=gdm.service
[Service]
Type=oneshot
ExecStart=/usr/bin/setkeycodes 1 58
ExecStart=/usr/bin/setkeycodes 3a 1
ExecStart=/usr/bin/setkeycodes e01d 100
ExecStart=/usr/bin/setkeycodes e038 97
[Install]
WantedBy=graphical.target
Enable the script so setkeycodes commands will automatically executed when gdm starts
systemctl enable custom-keys
The next time you reboot your system, key changes will take effect. To test if your config works, try
systemctl start custom-keys
Offline