Martin Frost

Add a custom keyboard layout in GNOME using rcm

Published:

I have recently switched to using GNOME as my daily desktop environment for my computer, and I of course want to use my custom keyboard layout, that I used to set up via my dotfiles, using rcm.

After some searching around for a bit, I encountered this nice article which explained how to get this to work.

Here's the layout file, which goes in ~/.xkb/symbols/frost:

// This is basically a US Dvorak with some (mostly) Swedish accented characters added
// å -> alt-gr a
// ä -> alt-gr e
// ö -> alt-gr o
// é -> alt-gr u
// ü -> alt-gr y

default partial alphanumeric_keys
xkb_symbols "dvorak" {
    include "us(dvorak)"
    include "level3(caps_switch)"
    include "level3(ralt_switch)"

    name[Group1] = "Swedish (Frost Dvorak)";

    //             Unmodified       Shift           AltGr            Shift+AltGr

    // // symbols row, left side
    key <AD05> { [ y,               Y,              udiaeresis,      Udiaeresis ] };

    // home row, left side
    key <AC01> { [ a,               A,              aring,           Aring      ] };
    key <AC02> { [ o,               O,              odiaeresis,      Odiaeresis ] };
    key <AC03> { [ e,               E,              adiaeresis,      Adiaeresis ] };
    key <AC04> { [ u,               U,              eacute,          Eacute     ] };
};

Then there are the evdev and evdev.xml files, which also goes in the ~/.xkb/rules directory:

Here's ~/.xkb/rules/evdev:

! options = symbols
  frost:dvorak = +frost(dvorak)
! include %S/evdev

And ~/.xkb/rules/evdev.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xkbConfigRegistry SYSTEM "xkb.dtd">
<xkbConfigRegistry version="1.1">
	<layoutList>
		<layout>
			<configItem>
				<name>frost</name>
				<shortDescription>frost</shortDescription>
				<description>Frost Dvorak</description>
				<countryList>
					<iso3166Id>SE</iso3166Id>
				</countryList>
				<languageList>
					<iso639Id>swe</iso639Id>
				</languageList>
			</configItem>
		</layout>
	</layoutList>
</xkbConfigRegistry>

Now I can update my keyboard settings to include my custom layout. After changing it, I'll have to log out and back in again in order to be able to use it.

After putting those in the respective place, I run mkrc on them to put them in my dotfiles.

mkrc .xkb/symbols/frost .xkb/rules/*