How do you set Ctrl + Alt = Alt Gr or ISO_Level3_Shift? (wayland)

I can only find solutions for x11 on the internet, but not for wayland. However, it seems to be a very common problem in general and one that affects all European layouts, not just German keyboards. And yet, the solutions for wayland are not properly documented.

It’s just annoying as a former Windows user (but unfortunately not “former” at work) to have to throw 20 years of typing habits out the window. Especially when it comes to programming.

I’m also a little surprised that KDE doesn’t have a simple GUI option for this yet, since KDE also comes from Germany (I know that this problem is independent of the desktop environment).

Not sure…

I created my own layout ‘ak’ for my new keyboard…
/usr/share/X11/xkb/symbols/

It now looks like this:
 default partial alphanumeric_keys
xkb_symbols "ak" {
    // Base layout (US International with dead keys)
    include "us(intl)"
    name[Group1] = "English (AK Custom)";
    include "level3(ralt_switch)"  // Enable AltGr as 3rd-level modifier

    // Dead keys moved to level3
    key <TLDE> { [ grave, asciitilde,  dead_grave,   dead_tilde ] };      // ~ ` dead keys è ẽ
    key <AC11> { [ apostrophe, quotedbl, dead_acute, dead_diaeresis ] };  // ' " dead keys é ë

    // Custom symbol overrides
    key <AE01> { [ 1, exclam,      onesuperior,  exclamdown    ] };       // 1 !        // ¹ ¡
    key <AE02> { [ 2,              at,   twosuperior,   onehalf] };       // 2 @ x² ½
    key <AE04> { [ 4, dollar,      sterling,     Thai_baht     ] };       // 4 $ £ ฿ (AltGr+4 = £)(AltGr+Sh_4 = ฿)
    key <AE05> { [ 5, percent,     EuroSign,     yen           ] };       // 5 % €  (AltGr+5 = € (Shift = ¥))
    key <AD03> { [ e, E,           EuroSign,     Ediaeresis    ] };       // e E € Ë (AltGr+E = €)
    key <AB02> { [ x, X,           U00D7,       U00B7          ] };     // x X × ·
    key <AB04> { [ v, V,           registered,   trademark     ] };       // v V ® ™
    key <AB05> { [ b, B,           periodcentered, dead_stroke ] };       // b B ·
    // Updated keys for quotes:
    key <AD11> { [ bracketleft,  braceleft,  U201C,        U00AB      ] };  // [ { “ «
    key <AD12> { [ bracketright, braceright, U201D,        U00BB      ] };  // ] } ” »

    // Special fractions/accents
    key <AE06> { [ 6, asciicircum, dead_circumflex, onequarter ] };       // 6 ^ dead^ ¼
    key <AE07> { [ 7, ampersand,   dead_horn,       onehalf ] };          // 7 & dead̛ ½
    key <AE08> { [ 8, asterisk,    dead_ogonek,     threequarters ] };    // 8 * dead˛ ¾
};

So now I use RightAlt as Alt_Gr and can type 2² - 2AltGr2 and € is RAltE for me… then on x we have × and ⋅ (for 2×2 or 2⋅2) and so on.

Additionally, there’s .XCompose - my CapsLock key is now my compose key…

<Multi_key> : “∴” U2234 # : . THEREFORE

~ and ~ makes ≈… and so on.

XCompose with the compose key are revolutionary tools.

Here’s an extract from my .XCompose (can’t post it all for various reasons)…

Summary
# --- My Additions ---

<Multi_key> <p> <r> <e> : "Respond as a neutral processor. Adhere strictly to the following: Provide factual, concise answers without speculation. Omit self-reference, prefaces, opinions, and filler language. Query follows :-"
<Multi_key> <w> <a> <n> <d>             : "🪄"
<Multi_key> <c> <h> <e> <m>				: "🧪"
<Multi_key> <t> <o> <o> <l>				: "🛠"
<Multi_key> <p> <e> <n>				: "🖉"

<Multi_key> <k> <b> <e> <n> <t>         : "<kbd>⏎Enter</kbd>"
<Multi_key> <e> <n> <t>	            : "⏎"	U23CE	# RETURN ENTER
<Multi_key> <r> <e> <t>		            : "⮐"
<Multi_key> <c> <a> <p>                 : "⇪"
<Multi_key> <k> <b> <c> <a> <p>         : "⇪CapsLock"
<Multi_key> <c> <o> <m> <m> <a>         : "❟"  # Large Comma (low quote)
<Multi_key> <c> <m> <d>                 : "⌘"   # CMD keyboard
<Multi_key> <a> <l> <t>                 : "⎇"   # Alt Keyboard
<Multi_key> <c> <t> <l>                 : "^"   # Ctrl Keyboard
<Multi_key> <p> <g> <u>                 : "⇞"   # Page Up
<Multi_key> <p> <g> <d>                 : "⇟"   # Page Down
<Multi_key> <h> <a> <m>                 : "☰"   # Hamburger Menu
<Multi_key> <c> <o> <g>                 : "⛭" # cog menu
<Multi_key> <m> <i> <c> <r> <o>         : "µ"   # micro Also <AltGr><m> = µ
<Multi_key> <n> <u> <m>                 : "№"   # numero
<Multi_key> <g> <b> <p>                 : "₤"   # Also ?<AltGr><Shift><$> is £
<Multi_key> <p> <y> <g>                 : "₲"
<Multi_key> <t> <h> <a> <i>             : "ไทย" # Thai
<Multi_key> <b> <t>                     : "฿"   # Thai Baht
<Multi_key> <d> <i> <v>                 : "÷"   # Also AltGr_Shift_+
<Multi_key> <d> <o> <t>					: "⋅"	# Multiply Dot
<Multi_key> <o> <h> <m>                 : "Ω"
<Multi_key> <d> <e> <g> <c>             : "°C" # >>> [⇧Shift][AltGr][ : ] = °°°°°
<Multi_key> <d> <e> <g> <f>             : "℉"   U2109  # DEGREE FAHRENHEIT

I did it with keyd:

First you create a new config file with nano:

❯ sudo nano /etc/keyd/default.conf

Then you write this in the config file:

[ids]

##internal laptop keyboard

0001:0001:09b4e68d

[control+alt]

##When Control+Alt are both held, these keys behave as if AltGr (RightAlt) is held.

##Numbers. ‘G’ is short for ‘AltGr’ in keyd.

2 = G-2
3 = G-3
7 = G-7
8 = G-8
9 = G-9
0 = G-0

# key (usually ‘minus’)

minus = G-minus

##Letters

q = G-q
e = G-e
m = G-m

##+ key (‘keyd monitor’ saw this as ‘]’)

] = G-]

##< key (ISO 102nd key)

102nd = G-102nd

At [ids] it didn’t work if you put * under it, which basically means “apply to all devices”. You need to find your keyboard ID with sudo keyd monitor and write that instead.

This config is for the standard German-layout and you can basically copy and paste it (except the keyboard ID! You need to provide yours!).

It won’t change the behavior of your other Ctrl+Alt shortcuts either with the exception of Ctrl+Alt+M and Ctrl+Alt+0 shortcuts in “Konsole”. If you want to mitigate that do as follows:

Open Konsole, press Ctrl+Alt+, –> Search for “Ctrl+Alt” in the search bar and change the Ctrl+Alt+M shortcut to e.g. Ctrl+Alt+B and change Ctrl+Alt+0 to Ctrl+Alt+´

Now everything should work fine. If you made a config mistake with keyd, so that your keyboard is somehow non-functional you can always end keyd with Backspace+Enter+Escape.

(I wrote this as a small tutorial in case somebody searches for this exact issue, like I was before figuring it out for myself.)

1 Like