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 the 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!

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)"
};
Explanation
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
= aShift+a
= AMode_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 Apr 01, 2023