I’ve been struggling a lot trying to remap a key to something else, in a way that propagates to all AppVMs. It appears there’s no straight-forward way to do it as of R4.2, and I’m going to collect here the observations I’ve made along the way.
- The basic way to accomplish this in Linux is by issuing
xmodmap -e keycode <keycode> = <keysym>
. To find out whatkeycode
a particular key on your keyboard issues, you have to use a program calledxev
; this isn’t installed in dom0, but comes with the debian template. So just start a terminal in a debian AppVM, runxev
and then press the key on your keyboard; it will tell you its keycode. Thekeysym
value corresponds to what the clients (apps) actually receive; possible values includea
,equal
, etc.- By doing this in qubesOS, you can remap a particular key to something else, but only in dom0. Unfortunately, the change doesn’t propagate to any AppVMs.
- Alternatively, you can change your entire keyboard layout. In dom0, the files containing layout definitions are located in
/usr/share/X11/xkb/symbols/
. You can change the layout usingsetxkbmap <layout>
, where<layout>
is the name of one of those files.- Surprisingly, changing the layout does propagate to AppVMs. I’m not sure how this happens, but the value of
qvm-prefs <appvm> keyboard_layout
updates right away after issuingsetkbmap
in dom0. And issuingsetxkbmap -print -verbose
in an AppVM shows that the new layout was added to thesymbols
entry. - This gave me the idea of maybe getting the remapped key to propagate to AppVMs, by editing the layout file in
/usr/share/X11/xkb/symbols/
accordingly. But doing so again results in remapping it for dom0 and not for AppVMs. - You can also create a new layout file, with your own changes, and save it as
/usr/share/X11/xkb/symbols/my-map
. Then you can activate it usingsetxkbmap my-map
. This results in the new layout working in dom0; but AppVMs will not change their layout.
- Surprisingly, changing the layout does propagate to AppVMs. I’m not sure how this happens, but the value of
- So taking everything into account, it seems that AppVMs receive the keycode directly, not a keysym. And the translation to a keysym is left up to the AppVM. There’s probably some Qubes service that runs in dom0 and in AppVMs, which registers when the keyboard layout is changed in dom0 and signals it to AppVMs; then the AppVM chooses to update its own layout. If the AppVM doesn’t have a layout file which corresponds to the layout name in dom0, no change takes place.
So, like I said. There’s no straight forward way to remap a key in qubesOS. It seems like the only way forward is to add the xmodmap
command in the startup scripts for each individual AppVM. So I’m now looking into how to use salt to do this.