Swedish characters w/ a French Canadian layout

Admittedly a weird mix, but it's what I need

Swedish has three additional characters in its alphabet: Ää, Öö and Åå. The first two can be typed with any layouts supporting diaereses (¨) but the third one can't be typed on any layout except the Scandinavians and the US-International ones (also Faviconthe UK extended one but exclusively on ChromeOS, weird)

However, despite needing those characters, I use the layout I'm most accustomed to due to growing up with it which is : The French Canadian keyboard (it's basically QWERTY with accents) so in this article, let's figure out together how to add Åå to my keyboard on Linux. Nu går vi!

Swedish keyboard Layout

The Swedish keyboard. Credit: FaviconWikipedia

As you can see on the image above, the characters are normally on their own key. Let's start with a controversial take: We won't do this

Of course, Åå being its own character, the "correct" way would be for it to be on its own key however, where the Swedish layout has all the brackets on the number row, the French Canadian's doesn't so we don't have room to have a key for it so we'll do another controversial thing and put it on.. the letter A 😄

The layout file

I use Wayland, but the process should be about the same on Xorg, first let's create a new layout in /usr/share/X11/xkb/symbols, we'll name it caswe

The final content will be the following (don't worry, we'll go through it!):

default partial
xkb_symbols "swe" {
include "ca(fr)"
name[Group1]= "Canadian French + Swedish Å";
key <AC01> { [a, A, aring, Aring ] };
include "level3(lalt_switch)"


We first define a new symbol map named swe, the first line tell XKB that this symbol map is the default one for this layout and that it is a partial, aka it doesn't cover the entire keyboard

include "ca(fr)"

Since this is supposed to be based on the French Canadian layout, we include it in our symbol map, everything defined after will replace the definitions added in the original layout while keeping unmodified lines

name[Group1]= "Canadian French + Swedish Å";

We then give a name to the current group. To be honest, I'm not sure what this is used for - the documentation about it isn't really clear however it's needed for the configuration to work

Now here come the important line:

key <AC01> { [a, A, aring, Aring ] };

key here says that this line describe a single mapping for a keycode, in this case AC01. The first letter indicate the block in which the key is located, here it's A for the alphanumeric key block, the second and the last two numbers are for the position of the key counting from the left and skipping over special keys such as Tab, Caps Lock etc

{ [a, A, aring, Aring ] }

This part says which character to output when the key is pressed, you might be wondering why there's 4 characters but it's actually pretty simple: the first one a is the normal character inputted when no modifiers are pressed, the second one A is when Shift and the key are pressed, the third one å is when Mode_switch and the key are pressed and finally the last one Å is when Mode_switch, Shift and the key are pressed. To resume:

  • a = a
  • Shift+a = A
  • Mode_switch+a = å
  • Mode_switch+Shift+a = Å

Mode_switch is most of the time AltGr but it's a actually bit more complicated than that, I recommend reading the documentation about it as it is fairly outside of the scope of this page. AltGr being a not so reachable key, we will remap it to left Alt using the following import:

include "level3(lalt_switch)"

And that's it for the layout file! This isn't needed on Sway with Wayland but if you were using let's say GNOME with Xorg, you would also need to add the keyboard layout to the following files: /usr/share/X11/xkb/rules/evdev.xml and /usr/share/X11/xkb/rules/evdev.lst otherwise it won't appear in the graphical tools for choosing your layouts

Using the layout on Sway

Set xkb_layout to our newly created file (caswe) and the variant to one we created (swe) in your Sway config files, like so:

input * {
xkb_layout caswe
xkb_variant swe

Restart Sway and you're done! Vi gjorde det!

Page last modified Feb 03, 2024


Toggle mobile menu