I replaced .Xmodmap file by /etc/X11/xorg.conf.d/01-keyboard.conf (which extends my base keyboard config 00-keyboard.conf) with
Section "InputClass"
Identifier "capslock to escape"
MatchIsKeyboard "on"
Option "XKbOptions" "caps:escape"
EndSection
And it works perfectly
]]>vconsole.conf only sets the mapping for linux console
Yup.
There's actually an xkb option "caps:swapescape" or "caps:escape" which you could use rather than xmodmap (adding that option to your xorg conf will maintain the behavior when the keyboard gets re-added, eg. after an S3)
Limiting the effect to a VTE is gonna be tricky ("impossible") because caps lock acts as a toggle for the shift modifier (ie. this is not a "real" key)
For "normal" keys at least xterm allows to override their behavior, eg.
xterm.vt100.translations: #override <Key>KP_Delete:string(.)
can be handy for numpad centric xterms outside US locales.
]]>So alter the X mapping is the good way to go, for example using ~/.Xmodmap like described in the main post.
Thank you all.
]]>here is the updated file
/usr/share/X11/xkb/symbols/us
___________________________________
default partial alphanumeric_keys modifier_keys
xkb_symbols "basic" {
name[Group1]= "English (US)";
key <INS> { [ KP_End, KP_Ins ] };
key <TLDE> { [ grave, asciitilde ] };
key <AE01> { [ 1, exclam ] };
key <AE02> { [ 2, at ] };
key <AE03> { [ 3, numbersign ] };
key <AE04> { [ 4, dollar ] };
key <AE05> { [ 5, percent ] };
key <AE06> { [ 6, asciicircum ] };
key <AE07> { [ 7, ampersand ] };
key <AE08> { [ 8, asterisk ] };
key <AE09> { [ 9, parenleft ] };
key <AE10> { [ 0, parenright ] };
key <AE11> { [ minus, underscore ] };
key <AE12> { [ equal, plus ] };
key <CAPS> { [ KP_Home, KP_Home ] }; ##The line of interest ##
key <AD01> { [ q, Q ] };
key <AD02> { [ w, W ] };
key <AD03> { [ e, E ] };
key <AD04> { [ r, R ] };
key <AD05> { [ t, T ] };
key <AD06> { [ y, Y ] };
key <AD07> { [ u, U ] };
key <AD08> { [ i, I ] };
key <AD09> { [ o, O ] };
key <AD10> { [ p, P ] };
key <AD11> { [ bracketleft, braceleft ] };
key <AD12> { [ bracketright, braceright ] };
key <AC01> { [ a, A ] };
key <AC02> { [ s, S ] };
key <AC03> { [ d, D ] };
key <AC04> { [ f, F ] };
key <AC05> { [ g, G ] };
key <AC06> { [ h, H ] };
key <AC07> { [ j, J ] };
key <AC08> { [ k, K ] };
key <AC09> { [ l, L ] };
key <AC10> { [ semicolon, colon ] };
key <AC11> { [ apostrophe, quotedbl ] };
key <AB01> { [ z, Z ] };
key <AB02> { [ x, X ] };
key <AB03> { [ c, C ] };
key <AB04> { [ v, V ] };
key <AB05> { [ b, B ] };
key <AB06> { [ n, N ] };
key <AB07> { [ m, M ] };
key <AB08> { [ comma, less ] };
key <AB09> { [ period, greater ] };
key <AB10> { [ slash, question ] };
key <BKSL> { [ backslash, bar ] };
};
I'm sure there is a more intelligent way but for me it works at the moment
*Note: I found the key codes in /usr/share/X11/xkb/keycodes/evdev
]]>Also this sounds like an xy-problem. What itch do you ultimately want to scratch?
]]>I'm trying to map the CapsLock key to Escape only for console.
So I followed the doc without any changes and any success
What I did:
/usr/local/share/kbd/keymaps/personal.map
include "/usr/share/kbd/keymaps/i386/azerty/fr-pc.map.gz"
keycode 58 = Escape
/etc/vconsole.conf
KEYMAP="/usr/local/share/kbd/keymaps/personal.map"
I have checked the key code of CapsLock which is 58, with the following:
# showkey -k
kb mode was ?UNKNOWN?
[ if you are trying this under X, it might not work
since the X server is also reading /dev/console ]
press any key (program terminates 10s after last keypress)...
keycode 28 release
keycode 58 press
keycode 58 release
keycode 58 press
keycode 58 release
And finally I reloaded successfully the config with loadkeys /usr/local/share/kbd/keymaps/personal.map and even with restarting the laptop -> 0 change at all
I also tried directly under X with xmodmap and ~/.Xmodmap:
clear lock
keycode 66 = Escape
And it works perfectly but the CapsLock key is mapped to Escape in the whole X and that's not what I want.
Why it does not work for virtual console ?
Note: I also tried by replacing 58 by 66 but no success too
Infos:
localectl status
System Locale: LANG=fr_FR.UTF-8
VC Keymap: /usr/local/share/kbd/keymaps/personal.map
X11 Layout: fr
X11 Model: pc
sudo dumpkeys -k | grep 58
keycode 58 = Escape
shift altgr keycode 58 = VoidSymbol
shift control keycode 58 = VoidSymbol
shift altgr control keycode 58 = VoidSymbol
shift alt keycode 58 = VoidSymbol
altgr alt keycode 58 = VoidSymbol
shift altgr alt keycode 58 = VoidSymbol
Linux 5.0.0-arch1-1-ARCH #1 SMP PREEMPT Mon Mar 4 14:11:43 UTC 2019 x86_64 GNU/Linux
]]>