0

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:

default
xkb_symbols "basic" {

    include "de"

    name[Group1]="de";
    name[Group2]="de2";

    // the H button should become accent grave when in second group
    override key <AC06> {
        type[Group2]="ALPHABETIC",
        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

<layout>
  <configItem>
    <name>de_ext</name>
    <shortDescription>xy</shortDescription>
    <description>German extended</description>
    <languageList>
      <iso639Id>ger</iso639Id>
    </languageList>
  </configItem>
</layout>

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[group1]="German";
    name[group2]="German";
    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 Jan 23 '18 at 18:05
  • @quixotic you're right - thank you. Please have a look at my edit. – Salim Jan 24 '18 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 Jan 24 '18 at 17:18
  • @quixotic I did and I noticed a few things. Could you have a look on the second Edit please? – Salim Jan 25 '18 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 Jan 25 '18 at 12:35
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

  • 1
    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 Jan 28 '18 at 2:16
  • But how could I define a new layout variant that only changes the second group? – Salim Feb 2 '18 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 Feb 3 '18 at 5:34

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.