5

I have a custom X11 keyboard layout that I can use with setxkbmap. But after some searching I've found that apparently just having the XKB layout file isn't enough to set it as a new keyboard layout in KDE 4. What I would like to have my custom layout be recognized by the KDE system so that I can choose it using the systray applet, or install it as the default using the System Settings module. What do I need to do to make this happen? If it's complicated, that's fine, I would still like to know what is involved.

I've looked at this question which seemed to be related, but it apparently is about creating the keyboard layout in the first place, which I've already done.

2 Answers 2

5

You need to tell the system that you have that file. I will not tell you how to modify the files -- you will figure it out -- but I will tell you which files to modify.

First, the layouts itself are in /usr/share/X11/xkb/symbols/. You can either copy the file there with a new extension, or modify one of the existing files to add your layout variant. For example, if your layout is based on the German layout, add a section to /usr/share/X11/xkb/symbols/de.

Finally, you need to modify /usr/share/X11/xkb/rules/evdev.lst and /usr/share/X11/xkb/rules/evdev.xml and add information about your layout / layout variant.

0
3

Here is a bit more detailed answer for anybody stuck on this.

How to make a custom keyboard layout in KDE

  • All you have to look at are these files:
    • /usr/share/X11/xkb/symbols/
    • /usr/share/X11/xkb/rules/evdev.xml
    • /usr/share/X11/xkb/rules/evdev.lst
  1. First in /usr/share/X11/xkb/symbols you can find a lot of keyboard layouts categorized by the language. There are a lot of gems in these files take a look if you don't like a layout already if you do skip to 3.
  2. In case you haven't decided for a keyboard layout there We will create a new block for our layout.
  • choose the language you want to have your keyboard layout based on
  • open that file and create a new block with an ID and a name:
xkb_symbols "keyboard_id" {// unique keyboard id
  include "us" // the keyboard you are based on
  name[Group1]= "my keyboard"; // the keyboard name that will be shown in the menus

  // your configuration will later go here

  include "level3(ralt_switch)" // optional switch to allow alt+gr and alt+gr+shift to be used
};
  1. We will come back here later. First we have to make it readable by the system. open /usr/share/X11/xkb/rules/evdev.lst
  • Search for the file name of the file where you put the keyboard layout block in (in my case it's cz) and put a new entry in there like this: keyboard_id cz: my keyboard
  • while replacing the keyboard_id cz and my keyboard with your values
  • image
  1. Do a similar task in /usr/share/X11/xkb/rules/evdev.xml image

  2. If you have done everything correctly it should now appear in the keyboard layouts: image

  3. apply this keyboard layout. You can now type with the layout! But you propably want to make changes to the base layout (in our case us)

  4. Now we go back to 2. - you will need to define any keys that will be different from the layout you are basing your layout of (in the case here it is the us keyboard)

xkb_symbols "keyboard_id" {// unique keyboard id
    include "us" // the keyboard you are based on
    name[Group1]= "my keyboard"; // the keyboard name that will be shown in the menus

    key <AE01>  {[      plus,     exclam,            1,        1 ]};
    key <AE02>  {[    ecaron,         at,            2,   Ecaron ]};
    key <AE03>  {[    scaron, numbersign,            3,   Scaron ]};
    key <AE04>  {[    ccaron,     dollar,            4,   Ccaron ]};
    key <AE05>  {[    rcaron,    percent,            5,   Rcaron ]};
    key <AE06>  {[    zcaron,asciicircum,            6,   Zcaron ]};
    key <AE07>  {[    yacute,  ampersand,            7,   Yacute ]};
    key <AE08>  {[    aacute,   asterisk,            8,   Aacute ]};
    key <AE09>  {[    iacute,  parenleft,            9,   Iacute ]};
    key <AE10>  {[    eacute, parenright,            0,   Eacute ]};
    key <AE11>  {[     minus, underscore,     NoSymbol, NoSymbol ]};
    key <AE12>  {[     equal,       plus,   dead_caron, dead_acute]};

    include "level3(ralt_switch)" // optional switch to allow alt+gr and alt+gr+shift to be used
};

Explanation of what is going on

  • <AE01> - the identifier of the physical key. refer to other keyboard layouts in the files for reference
  • {[ first_key, second_key, third_key, fourth_key]);
    • first_key - key when pressed without other buttons presses
    • second_key - key when pressed with shift
    • third_key - key when pressed with alt+gr
    • fourth_key - key when pressed with alt+gr+shift
  • now if you have ommited include "level3(ralt_switch)" third and fourth key won't do anything and therefore you should have just two keys like so: key <AE10> {[ eacute, parenright]};
  • reorder the layouts and apply to see the changes after saving the file (or somehow other reload the keyboard layouts in your system. In the worst case just reboot) image
1
  • Excellent answer!
    – dns
    Dec 26, 2023 at 1:02

You must log in to answer this question.

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