I want to create a custom keyboard layout based on my German keyboard layout (de). The idea is to have a two-group layout and have the Caps-Lock to be the Mode_switch key. That remap seems to work according to xev. However, the second group layout does not work. When I press [CAPS]+[H] --> "h" occurs ("`" expected).

Here is my symbols file called de_ext:

xkb_symbols "basic" {

    include "de"


    // the H button should become accent grave when in second group
    override key <AC06> {
        symbols[Group2]= [           grave, grave ]

    override key <CAPS> {         [     Mode_switch, Caps_Lock ] };


Edit 1:

@quixotic is right, this actually works when set directly. I also tried copying the de_ext file to /usr/share/X11/xkb/ and then running setxkbmap de_ext which also works.

However, it does not work when adding the layout to /usr/share/X11/xkb/rules/evdev.xml with

    <description>German extended</description>

Although the new layout appears in my layout selection on my Ubuntu 17.04 taskbar, when I select it, the CAPS-Lock button has a different behavior as explained above. What works is that CAPS-Lock is the Mode_switch (I checked with xev), however, the second group doesn't seem to be selected because when pressing [CAPS]+[H] it doesn't work. Any idea what the difference could be when using the Ubuntu/Gnome Layout Switcher?

Edit 2: When calling xkbcomp $DISPLAY broken.xkb, these are the things I noticed:

  1. The name of my xkb_symbols is: xkb_symbols "pc+prg+de:2+us:3+inet(evdev)"
  2. My Layout has three groups instead of two (I noticed that even my default German layout gets two layouts although only one is defined in symbols/de)

    name[group3]="English (US)";
  3. Almost all keys get three groups / layouts, whereas the second is the same as the first and the third one is an English keyboard layout. My own changes to the letters are not included.

    key <AC01> {
        type[group1]= "FOUR_LEVEL_ALPHABETIC",
        type[group2]= "FOUR_LEVEL_ALPHABETIC",
        type[group3]= "ALPHABETIC",
        symbols[Group1]= [               a,               A,              ae,              AE ],
        symbols[Group2]= [               a,               A,              ae,              AE ],
        symbols[Group3]= [               a,               A ]
  4. Here is what I get for the letter H

    key <AC06> {
        type[group1]= "FOUR_LEVEL_ALPHABETIC",
        type[group2]= "ALPHABETIC",
        type[group3]= "ALPHABETIC",
        symbols[Group1]= [               h,               H,         hstroke,         Hstroke ],
        symbols[Group2]= [               h,               H ],
        symbols[Group3]= [               h,               H ]
  5. My change for the Caps-Lock button is included without modifications

What I assume: there must be some rule in the default (ubuntu?) xkb configuration which modifies all symbols to include additional layouts as an additional group. Is there any way I can stop that rule for my xkb symbol to fire?

  • 1
    this actually works for me ( setxkbmap -layout de -option -print > foo.xkb, edit foo.xkb and add these mods to the xkb_symbols section, then load with xkbcomp foo.xkb $DISPLAY). how are you loading these symbols? are you sure there's no option set that's conflicting? (clear with setxkbmap -option to be sure.)
    – quixotic
    Commented Jan 23, 2018 at 18:05
  • @quixotic you're right - thank you. Please have a look at my edit.
    – Salim
    Commented Jan 24, 2018 at 16:17
  • 1
    generate .xkb files for when it works and when it doesn't. when working: xkbcomp $DISPLAY working.xkb ... when not: xkbcomp $DISPLAY broken.xkb ... then compare the two to see what's different.
    – quixotic
    Commented Jan 24, 2018 at 17:18
  • @quixotic I did and I noticed a few things. Could you have a look on the second Edit please?
    – Salim
    Commented Jan 25, 2018 at 9:36
  • you've probably done this already, but just to verify: if you're in GNOME, make sure its kbd plugin is disabled, or it'll periodically reset things: see here or here ... alternately use i3wm or openbox or another gnome-less environment for testing.
    – quixotic
    Commented Jan 25, 2018 at 12:35

1 Answer 1


I finally found the solution. In the file /usr/share/X11/xkb/rules/evdev there is a rule

! model     layout[2]   =   symbols
  *         *           =   +%l[2]%(v[2]):2

Which causes to overwrite my second group with the default layout of my keyboard. I could fix this by adding the following line (where de is my base keyboard layout):

! model     layout[2]   =   symbols
  *         de          =   +de

Thank you @quixotic to help me analyzing the problem

  • 2
    i expect tweaking this rule works for you because you're defining two groups in the same map. most symbol files don't do that; they define a single group so rules like the original here can redefine the group easily. while this solution can work for your specific case, i would not recommend anyone else follow this approach. instead, split your layout into variants that work on one group at a time, and use the default rules to load the variants properly (setxkbmap -layout myde,myde -variant mygroup1,mygroup2 or similar).
    – quixotic
    Commented Jan 28, 2018 at 2:16
  • But how could I define a new layout variant that only changes the second group?
    – Salim
    Commented Feb 2, 2018 at 22:38
  • 1
    you'd write each variant to only configure Group1, like the predefined variants in /usr/share/X11/xkb/symbols/(layoutname). then when loaded with -layout myde,myde -variant mygroup1,mygroup2 the Group1 definitions in the mygroup2 variant are changed to Group2 instead.
    – quixotic
    Commented Feb 3, 2018 at 5:34
  • 1
    @quixotic, in my case, I use Mode_switch as a modifier to access group 2 mappings, i.e. CAPS + h,j,k,l maps left, down, up, right arrow keys. What would you recommend in that case?
    – user658991
    Commented Apr 23, 2019 at 18:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .