Use setxkbmap to swap the Left Shift and Left Control describes how to swap some modifier keys with xkbcomp. However, I'd like to just add a custom setxkbmap option instead of using xkbcomp with a full layout definition. Similar to setxkbmap -option local:swap_lwin_lctrl, I'd like to swap right win & right control without modifying existing files in /usr/share/X11/xkb (which would be overwritten on package upgrade).

1 Answer 1


I have the same issue. From the doc, one could guess that the correct syntax would be something like that :

$ setxkbmap -I$HOME/.config/xkb -option mine:accent

Note : ~ doesn't work with the -I option



partial default
xkb_symbols "accent" {
    include "level3(ralt_switch)"
    key <AE02>  { [  NoSymbol, NoSymbol, eacute,      NoSymbol ] };
    key <AE07>  { [  NoSymbol, NoSymbol, egrave,      NoSymbol ] };
    key <AE09>  { [  NoSymbol, NoSymbol, asciicircum, NoSymbol ] };
    key <AE10>  { [  NoSymbol, NoSymbol, agrave,      NoSymbol ] };

or whatever symbole file you have and


! option        =   symbols
  mine:accent   =   +azerty_altgr(accent)

Unfortunately, it doesn't work.

The only solution I found is the following : Use the same files described above. Set all native option using setxkbmap -option caps:swapescape,whatever. Then :

$ setxkbmap -print > tempfile.txt

and edit tempfile.txt in order to add your custom option in the xkb_symbols line :

xkb_keymap {
    xkb_keycodes  { include "evdev+aliases(qwerty)" };
    xkb_types     { include "complete"  };
    xkb_compat    { include "complete"  };
    xkb_symbols   { include "pc+us+fr:2+inet(evdev)+capslock(swapescape)+azerty_altgr(accent)"  };
    xkb_geometry  { include "pc(pc104)" };

and finaly :

xkbcomp -I$HOME/.config/xkb tempfile.txt $DISPLAY

It can be generalised for any number of options. This solution is deprecated according to Archlinux wiki.

  • Great, thanks for this! I can confirm that it is still working as of 2018-01-25, and the archwiki warning has been updated to indicate that it might not be deprecated. Jan 25, 2018 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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