Ubuntu / Linux Custom Keyboard, US Layout with RO and DE characters

As I recently decided to switch to Ubuntu, I needed a custom keyboard layout with both Romanian special characters (ă, â, î, ț, ș) and the German ones also (ä, ö, ü, ß), so I won’t be forced to switch between layouts all the time. This example can be used also to edit other layouts and create your own custom keyboard.

My keyboard looks like this:

kb_ro-de

How I’ve accomplished this:

In this case it’s necessary to edit two files:

/usr/share/X11/xkb/rules/evdev.xml
/usr/share/X11/xkb/symbols/ro

In the first file, “/usr/share/X11/xkb/rules/evdev.hml”, we search for the begining of Romanian keyboard, and insert our layout as a new “<variant>…</variant>” like this:

...
  <shortDescription>ro</shortDescription>
  <description>Romanian</description>
  <languageList>
    <iso639Id>rum</iso639Id>
  </languageList>
 </configItem>
 <variantList>
  <variant>
   <configItem>
    <name>ro_prg_de</name>
    <description>Romanian (Programmers+DE)</description>
   </configItem>
  </variant>
  <variant>
   <configItem>
    <name>cedilla</name>
    <description>Romanian (cedilla)</description>
  </configItem>
  </variant>
...

Now we need to edit the next file, “/usr/share/X11/xkb/symbols/ro”, where we search the “cedilla” version again and input our layout like this:

...
  key <AB09> { [ period, greater, guillemotright ] };

 include "level3(ralt_switch)"
};

partial alphanumeric_keys
xkb_symbols "ro_prg_de" {
 // Variant of the basic layout with German characters.

 include "ro(basic)"

 name[Group1]="Romanian (Programmers+DE)";

 key <AB01> { [ z, Z, adiaeresis, Adiaeresis ] };
 key <AB02> { [ x, X, ssharp ] };
 key <AD04> { [ r, R, registered ] };
 key <AD07> { [ u, U, udiaeresis, Udiaeresis ] };
 key <AD09> { [ o, O, odiaeresis, Odiaeresis ] };
};

partial alphanumeric_keys
xkb_symbols "cedilla" {
 // Variant of the basic layout with cedillas.
 // Implements S and T with cedilllas as in ISO-8859-2.
 // Included for compatibility reasons (this used to be the def variant).
...

Reload keyboard profiles:

sudo dpkg-reconfigure xkb-data

Now reboot your computer and after restart add your new keyboard:

add-kb

For those who will need my exact layout I’ve made an install script also, just download it below [tested only in Ubuntu 14.04 LTS]:

Download kb-ro.de

Usage:

cd /tmp/
wget https://www.net-zone.ro/download/kb-ro.de
sudo kb-ro.de install

To uninstall just repeat the steps above and issue “uninstall” :)

P.S.: I’ve made a custom keyboard with the same layout for Windows also, but I’ll post it first time I will log into Windows again… 😛