Score:0

English keyboard layout in Ubuntu that is very close to macOS one but allows Compose key

pk flag

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!

Gunnar Hjalmarsson avatar
uz flag
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)?
Score:1
pk flag

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
    
Score:1
uz flag

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)"
Dmitry Kabanov avatar
pk flag
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.
Gunnar Hjalmarsson avatar
uz flag
@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.
Dmitry Kabanov avatar
pk flag
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 avatar
pk flag
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 avatar
pk flag
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!
Gunnar Hjalmarsson avatar
uz flag
@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 avatar
uz flag
@DmitryKabanov: As regards the compose key, you may have hit [this bug](https://launchpad.net/bugs/1969396).
Dmitry Kabanov avatar
pk flag
Yes, it looks like this from the commands. I've never used Wayland so far.
Dmitry Kabanov avatar
pk flag
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.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.