[qubes-users] Changing key mappings / running a command at startup


I'm used to swapping CapsLock and Escape keys, but don't manage it to
do it through vms. Any help?

Basically what I need is not more complicated than running xmodmap
config_file, where config_file is:
remove Lock = Caps_Lock
keycode 9 = Caps_Lock
keycode 66 = Escape
add Lock = Caps_Lock

Several years ago I was using Qubes 3.2, and if I remember correctly I
only had to do it in dom0, then it was propagated to vms. This does
not work anymore in 4.1.

Currently, when doing it in dom0 it works in dom0, but when starting a
vm I get this weird situation:
- CapsLock key does nothing,
- Escape key sends both Escape and CapsLock.

I can manually run xmodmap config_file in vms, then it is fine, but I
can't automate it. At startup:
- ~/.Xmodmap is not read
- ~/.xsession is not executed
- /rw/config/rc.local is executed, but adding "xmodmap
/home/user/config_file" in it does nothing.
- I tried adding a script in the template,
/etc/X11/Xsession.d/99script, containing "xmodmap
/home/user/config_file", but it does not work either (though the
script is executed).

I found this thread, but don't understand anything, and I can't figure
such a simple thing could be that complicated.

1 Like

"solved". Ugly, but works. Via a .desktop in ~/.config/autostart. The
trick was to not run xmodmap immediately, but to delay it: sleep 2;
xmodmap /home/user/...

For the record:
[Desktop Entry]

sleep 2; xmodmap /home/user/.config/xmodmap

remove Lock = Caps_Lock
keycode 9 = Caps_Lock
keycode 66 = Escape
add Lock = Caps_Lock

Also added to /etc/skel/ of the templates for future vms and dispvms.


I have something similar, but how can I run something in dom0 every time
sys-usb restarts? I currently have in dom0
Exec=/usr/bin/setxkbmap -option ctrl:nocaps

However, every time I restart sys-usb, my USB keyboard loses that
setting and I must manually run setxkbmap.