Skip to content

Instantly share code, notes, and snippets.

@AntonFriberg
Last active October 16, 2024 09:45
Show Gist options
  • Save AntonFriberg/2864f4a242c31cab3b505045bb0d68b0 to your computer and use it in GitHub Desktop.
Save AntonFriberg/2864f4a242c31cab3b505045bb0d68b0 to your computer and use it in GitHub Desktop.
Swerty Keyboard Layout with working Alt-Gr on Linux Debian 10

Background

The Swerty keyboard layout is created by Johan E. Gustafsson and hosted on http://johanegustafsson.net/projects/swerty/

Swerty is released under the MIT Licence.

Since I spend a lot of time getting the right alt-gr key to work I decided to share back my fixes.

Installation

Installation instructions: Swerty for Linux

Add the contents of se.txt to the end of the file /usr/share/X11/xkb/symbols/se.

$ sudo bash -c 'cat se.txt >> /usr/share/X11/xkb/symbols/se'

Then look up the following section in the file /usr/share/X11/xkb/rules/evdev.xml:

    <layout>
      <configItem>
        <name>se</name>
        <shortDescription>Swe</shortDescription>
        <description>Sweden</description>
        <languageList><iso639Id>swe</iso639Id></languageList>
      </configItem>
      <variantList>

Add the following variant block after the line :

        <variant>
          <configItem>
            <name>swerty</name>
            <description>Swerty</description>
          </configItem>
        </variant>

Finally, after the line ! variant in the file /usr/share/X11/xkb/rules/evdev.lst add the following line:

  swerty          se: Swerty

Now Swerty should show up as one of the alternative keyboard layouts for Swedish.

US & Swerty Toggle

Since the US layout is still more suitable in some cases (e.g. for coding). It is nice to be able to quickly change between the US and Swerty layout using the "win+space" key combination.

This can be accomplished with

$ setxkbmap -layout 'us,se' -variant ',swerty' -option 'grp:win_space_toggle'
//Swerty by Johan E. Gustafsson
partial alphanumeric_keys
xkb_symbols "swerty" {
name[Group1]="Sweden - Swerty";
key <TLDE> { [ grave, asciitilde, section, onehalf ] };
key <AE01> { [ 1, exclam ] };
key <AE02> { [ 2, at, quotedbl ] };
key <AE03> { [ 3, numbersign, sterling ] };
key <AE04> { [ 4, dollar, currency ] };
key <AE05> { [ 5, percent, EuroSign ] };
key <AE06> { [ 6, asciicircum, dead_circumflex ] };
key <AE07> { [ 7, ampersand, braceleft ] };
key <AE08> { [ 8, asterisk, bracketleft ] };
key <AE09> { [ 9, parenleft, bracketright ] };
key <AE10> { [ 0, parenright, braceright ] };
key <AE11> { [ minus, underscore, dead_diaeresis, dead_circumflex ] };
key <AE12> { [ equal, plus, dead_tilde ] };
key <AD01> { [ q, Q ] };
key <AD02> { [ w, W ] };
key <AD03> { [ e, E, EuroSign ] };
key <AD04> { [ r, R ] };
key <AD05> { [ t, T ] };
key <AD06> { [ y, Y ] };
key <AD07> { [ u, U ] };
key <AD08> { [ i, I ] };
key <AD09> { [ o, O, braceleft ] };
key <AD10> { [ p, P, braceright ] };
key <AD11> { [ aring, Aring, bracketleft, braceleft ] };
key <AD12> { [dead_acute, dead_grave, bracketright, braceright ] };
key <AC01> { [ a, A ] };
key <AC02> { [ s, S ] };
key <AC03> { [ d, D ] };
key <AC04> { [ f, F ] };
key <AC05> { [ g, G ] };
key <AC06> { [ h, H ] };
key <AC07> { [ j, J ] };
key <AC08> { [ k, K ] };
key <AC09> { [ l, L ] };
key <AC10> { [ odiaeresis, Odiaeresis, semicolon, colon ] };
key <AC11> { [ adiaeresis, Adiaeresis, apostrophe, quotedbl ] };
key <BKSL> { [ backslash, bar ] };
key <AB01> { [ z, Z ] };
key <AB02> { [ x, X ] };
key <AB03> { [ c, C ] };
key <AB04> { [ v, V ] };
key <AB05> { [ b, B ] };
key <AB06> { [ n, N ] };
key <AB07> { [ m, M, mu ] };
key <AB08> { [ comma, less ] };
key <AB09> { [ period, greater, colon ] };
key <AB10> { [ slash, question ] };
// Add for working right alt-gr key
include "level3(ralt_switch)"
};
@SpamixOfficial
Copy link

SpamixOfficial commented Sep 8, 2024

Tack för denna fix! Behövde det på i3
/----------------------------------------------------/
Thanks for this fix! Needed it on i3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment