How to get both Alt keys to behave as Alt Gr does (Ubuntu 14.04, xkb) AND get dedicated keys for curly braces

Today I spend a ridiculously large amount of my time trying to find the answer to the above question.

This applies to Ubuntu 14.04 which uses XKB for the keyboard layout. And I’m using Gnome 3.

The answer was finally found when I checked the file called /usr/share/X11/xkb/symbols/level3.

Well. I’ll just skip this. I don’t really have time to write this post.

For me the file to edit is this:

sudo gedit /usr/share/X11/xkb/symbols/fi

That’s the finnish layout. But there’s many layouts inside it.

I added a new layout, but you could maybe just edit an existing one.

Here’s the addition:

partial alphanumeric_keys
xkb_symbols "coding" {

    // Finnish keyboard layout with coding enhancements, no dead keys

    include "fi(fi)"

    name[Group1]="Finnish (coding)";

    key <TLDE> { [  at,              onehalf,          section,               NoSymbol              ] };
    key <AE11> { [  braceleft,       question,         backslash,             questiondown          ] };
    key <AE12> { [  braceright,      grave,            cedilla,               ogonek                ] };
    key <AD12> { [  plus,            asciicircum,      asciitilde,            caron                 ] };
    key <AC09> { [  l,               L,                l,                     L                     ] };
    key <BKSL> { [  apostrophe,      asterisk,         caron,                 breve                 ] };
    key <AB08> { [  comma,           semicolon,        cedilla,               ogonek                ] };
    key <AB10> { [  minus,           underscore,       hyphen,                macron                ] };
    include "level3(alt_switch)"

If you only want ALT thing and not the curly brace thing (and still want dead keys), then remove all those lines starting with key!SOMEKEY! from the above. And only relevant lines for {} are AE11 and AE12, braceleft, braceright. The other lines are just copied from the no-dead-keys version.

Then you must add this new layout to

sudo gedit /usr/share/X11/xkb/rules/evdev.xml

Find your layout. I searched for “Finnish” and added this variant:

Finnish (coding)

Then update with:

sudo dpkg-reconfigure xkb-data

Change your layout from Gnome3’s upper right menu. Test. If it doesn’t work yet, log out. Good luck.


Other things to do:

Fix Command key (currently behaving as the Win key) to behave as Ctrl from the tweak settings (gnome-tweak-tool) or whatever that is.
(Translated from finnish it’s the setting under “Writing”, “Alt- and Win-keys settings” -> “Ctrl is set to Win-keys (and regular Ctrl-keys)”.)
You can fix Command+Tab from the keyboard shortcuts settings. Find Alt+Tab (or Super+Tab) and set it to Ctrl+Tab.

Linux would really need a visionary distro, that could fix computing to some sane defaults (for Mac users and other sane users). And if that is not possible, there should be easy to use GUI programs that could handle e.g. creating custom keyboard layouts. I found one python program from 2008, but as it was not included in any ubuntu repos, my guess is that it is not good enough. There’s a great program for OS X called Ukelele.

All I need:
– Gnome 3, with Nemo file manager or better. (Nautilus is the worst file manager of the decade. Ubuntu’s Unity is the worst desktop environment of the decade.)
– Close, minimize, maximize on the left side of the window. And I need all of them, not just close.
– Round window corners
– Both Alts do the same thing (The thing that the strange concept of Alt Gr does now.)
– Fix numlock. If I have a laptop that has an external keyboard connected to it, and want to use the numpad on it. Numlock behaviour is just broken, because if the need is: “I want all the keys to work on both my keyboards”, then Numlock in Ubuntu with a laptop, just isn’t the answer to this question.


One comment

  1. Funny. I wrote that in 2014. Now almost two years later with Ubuntu 16.04 I was tweaking the keyboard again. I googled but I found nothing good. I used about 30 mins and was already writing half of the same modifications on the same xkb file. But then I almost remembered that I might have written my only tutorial about this. So, I checked my blog, and here’s the answer.
    I couldn’t quite find the Win to Ctrl-keys thing, so I edited it a little, so that I’ll find it in 2018, when I’ll be needing this post again.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s