0

I am using Ubuntu 22.04 at work and macOS at home. Both computers have internional keyboards. That means that there is an extra button between left Shift and Z buttons.

However, I have the following problem. I´d like to using this extra button as it is used in macOS: for entering backtick ` and ~ characters because I use them extensively in both operating systems.

The problem is that when I choose "English (UK, Macintosh)" keyboard layout in Ubuntu, it does not allow to use Compose key to enter easily characters like ü and ä. I chose another layout ¨English (UK, Macintosh, intl.)¨ but it has superweird behavior with backticks, tilde, and double quotes as it expects me to enter something directly after that (for example ~n becomes ñ), which makes writing in Markdown or programming code a torture.

Is there a good English keyboard layout in Ubuntu 22.04 that 1) has backtick and tilde between left Shift and Z buttons; 2) Allows Compose button to enter special European characters like ü?

Thanks!

  • I posted an answer covering 1), but I don't really understand what you mean by 2). Did you see [the docs about compose keys](https://help.ubuntu.com/stable/ubuntu-help/tips-specialchars.html#compose)? – Gunnar Hjalmarsson Jul 27 '23 at 00:31

2 Answers2

1

On the English (UK, Macintosh) layout, the backtick and tilde symbols are actually mapped to the key to the left of the Z key.

However...

On some Apple devices, and for some reason, that key is switched with the key to the left of the number 1 key. So I assume that some Apple hardware is involved in your case.

In Ubuntu 20.04 there was a simple way to fix that:

Key '@' (Keycode 49) and key '<' (keycode 94) are inverted on macbookPro keyboard

But that Debian specific feature was dropped in Ubuntu 22.04.

One clumsier way to switch the keys back to their intended state is to edit the file in question directly. It's the /usr/share/X11/xkb/symbols/gb file and this diff shows what can be done:

--- gb.orig
+++ gb
@@ -188,8 +188,8 @@
 
     key <AE02> {   [               2,              at,         EuroSign    ]   };
     key <AE03> {   [               3,        sterling,       numbersign    ]   };
-    key <TLDE> {   [         section,       plusminus ]    };
-    key <LSGT> {   [           grave,      asciitilde ]    };
+    key <LSGT> {   [         section,       plusminus ]    };
+    key <TLDE> {   [           grave,      asciitilde ]    };
 
     include "level3(ralt_switch)"
     include "level3(enter_switch)"
Gunnar Hjalmarsson
  • 32,938
  • 3
  • 63
  • 94
  • yes, I tried to use the English (UK, Macintosh). However, as I said before, the Compose key stops working. This key allows to enter key sequences that are transformed to additional characters, for example ü in German. I have the Compose key mapped to Right Alt, and it does not work in this layout. It works in English (US) layout, however. – Dmitry Kabanov Jul 28 '23 at 08:15
  • @DmitryKabanov: That conflict can be dealt with in *Settings -> Keyboard -> Special Character Entry*. Please make up your mind about which layout you want to use. Otherwise it's hard to guide you further. – Gunnar Hjalmarsson Jul 28 '23 at 14:51
  • I did not quite understand. I have set the Compose key to the Right Alt key. However, in "English (UK, Macintosh)" keyboard layout, it stops working. So, it looks to me more like a bug than something that I did not set correctly. – Dmitry Kabanov Jul 31 '23 at 16:31
  • I would prefer to use English US keyboard layout but I need to put ` and ~ on the key between the Left Shift and Z keys. – Dmitry Kabanov Jul 31 '23 at 16:32
  • I actually tried a similar (to the one you suggested) solution via `xmodmap` and it worked for me: adding `~/.Xmodmap` with the line `keycode 94 = grave asciitilde` and then in the terminal `xmodmap ~/.Xmodmap`. Thank you for the help! – Dmitry Kabanov Jul 31 '23 at 16:45
  • @DmitryKabanov: Great! Would be good if you could submit an answer with that solution. Just a control question: It only works on X and not Wayland, right? – Gunnar Hjalmarsson Jul 31 '23 at 17:12
  • @DmitryKabanov: As regards the compose key, you may have hit [this bug](https://launchpad.net/bugs/1969396). – Gunnar Hjalmarsson Jul 31 '23 at 17:19
  • Yes, it looks like this from the commands. I've never used Wayland so far. – Dmitry Kabanov Aug 01 '23 at 15:41
  • thank you for the link to the bug. Apparently, this is exactly the bug that I have encountered, as the English (UK, Macintosh) is the second layout in the list, and the Rigth Alt works as an Alternative Symbols, although unset. However, now I am quite happy with English (US) layout, after I remapped the key between Left Shift and Z. – Dmitry Kabanov Aug 01 '23 at 20:43
1

This is what worked for me via xmodmap.

  1. Execute xev in the terminal and press the key between Left Shift and Z keys. In the terminal will appear the information about the keycode, which is required for the next step. For me, the keycode is 94.

  2. Add file ~/.Xmodmap with the line

    keycode 94 = grave asciitilde
    
  3. Execute in the terminal

    xmodmap ~/.Xmodmap