20

I am used to using US International as my keyboard layout. However, the implementation appears to differ greatly between Windows and Linux (Gnome, in my case – may well be a GTK issue since GTK behaves the same on Windows).

The layout uses dead keys, for example for keys such as ', ", ^, &c. allowing easy entry of characters with diacritics. On Windows pressing a dead key and then a key that has no pair associated results in the dead key's character (when paired with space) and the character from the second key. Example: Pressing ", a yields “ä”, however, pressing ', s yields “'s”, as there is no pairing for ' and s.

Now, there is a language called English which makes frequent use of exactly those two characters and since it works on Windows to just type them as usual it's muscle memory for me now. Which brings me to my problem:

On Linux (and GTK on Windows), there is a pairing for ' and s (among many others), resulting in ś (which, in turn, leads to me frequently typing “itś”). So typing “it's” requires me to type ',         , s at the end.

There are a few other combinations I'm used to that don't work. Among those is that for non-existant pairs simply nothing is the result. Typing “I'd” results in “I”. Hitting one of those keys twice results in a non-spacing diacritic which breaks my habit of typing strings by first typing both quotation marks (which now result in a non-spacing acute accent or macron).

Long story short: None of the supplied US International layouts appears to function the same as in Windows – are there any that do work identically? Or any chance to configure it that way? While it may be nice to type an s with acute accent or non-spacing diacritics, those aren't exactly common needs for me.

quack quixote
  • 43,504
Joey
  • 41,098

4 Answers4

10

Currently there is a github repo that provides a .deb file that solves this problem:

Windows™ US International XCompose for Linux

It is based on a customized .XCompose file as other answers have suggested.

From that page (Ubuntu/Debian):

sudo apt-add-repository -y ppa:rael-gc/utils
sudo apt update
sudo apt install win-us-intl
im-config -n uim

Logout and login. If that doesn't work, try rebooting the system.

yms
  • 818
7

One possibility is to avoid having dead keys and type accented letters with a Compose key instead. For example, type Compose " a to enter ä. You'll have to choose a keyboard layout option that includes a Compose key; a common choice is the key to the left of the right Ctrl key (which I think Windows calls Menu). The advantage of Compose is that you get to be able to type many fancy characters without changing your main layout. The disadvantage is that it takes three presses instead of two for an accented letter.

Alternatively, you can configure the effect of dead keys by creating a file called .XCompose (note CApitalization) in your home directory and listing the combinations you want. Something like:

include "/usr/share/X11/locale/en_US.UTF-8/Compose"

<dead_acute> <space> : "'" apostrophe
<dead_acute> <exclam> : "'!"
<dead_acute> <quotedbl> : "'\""
# etc...
<dead_acute> <a> : "á"
<dead_acute> <b> : "'b"
# etc...

The syntax is fairly simple: the sequence of keys to the left of the : is turned into the string between "" on the right of the :. The extra word on the right is the keysym (i.e., the name of the key) corresponding to this sequence of keys; it's not terribly important. Anything from a # to the end of the line is ignored.

Change the first line to point to the system file if your distribution puts it in a different place. You can look in this file for more syntax examples. <Multi_key> is another name for the Compose key.

On the left, the names between <angle brackets> are keysyms. You can find the list of keysyms in /usr/include/X11/keysymdef.h (this file is in a development package, e.g., x11proto-core-dev on Ubuntu).

Yes, that's a lot of typing, but you should be able to automate much of it by copy-pasting chunks of keysymdef.h and doing a few clever mass replacements. Something that will help is that you can reuse the hexadecimal code on the right to make the right-hand string thanks to the "\xdd" syntax: turn e.g.

#define XK_exclam                        0x0021  /* U+0021 EXCLAMATION MARK */

into

<dead_acute> <exclam> : "'\x21"

Finally, you can set up a keyboard layout with dead keys and a Compose key. Being German, you might set up only " as a dead key. If you're going that route, the simplest option is to use the GUI to set up a keyboard with no dead key and an .Xmodmap file for the dead key, containing something like

keysym apostrophe = apostrophe dead_quotedbl
3

I'm aware this question has been "solved" for a while. However, I want to present my solution, which combines the findings from this page with a lot of testing and experimentation.

Win US Intl for Linux is a series of scripts I wrote to solve the issue of having problems with the Linux's native US Intl keyboard layout, just as the OP wrote. I use it mainly because my mother language is Spanish, and I still use lots of English forums, texts, chats and so on (like this site).

To note: This is actually similar (not totally equal) to the behavior of Windows XP US - International keyboard layout.

You can go to http://tamh.info/en/win-us-intl-4-linux/ to check it out. I'm in the process of making it better, by adding more XCompose entries for several other borderline cases, among other changes.

warp
  • 243
Tamh
  • 151
2

So there is a solution, as someone posted here there is a github repo that can make this work: https://github.com/raelgc/win_us_intl Here what you want to do:

  1. download the zip file

  2. extract wherever you want, your focus should be on the XCompose file.

  3. Open the XCompose file with your preferred text editor, and then put bellow include "/usr/share/X11/locale/en_US.UTF-8/Compose" a line like this: include "%L"

  4. Move the XCompose file to the ~/ directory

  5. EDIT:

    • This step is no longer needed, It'll work out without it on all new editions of linux, if it doesn't work for you, only do this step if you know what you are doing because XIM have some known issues.
    • Edit your ~/.profile and put export GTK_IM_MODULE="xim" in the end of the file.
  6. EDIT:

    • If you are using GNOME: IBus comes pre-installed with this environment and changing to another input method won't have any effect because GNOME will start it anyway and configure the important variables.
    • If you don't want to use IBus, type this command in the terminal: im-config -n uim
  7. Reboot

Note: For me this solution doesn't work without step 5, so if you know how to help me and others in the same situation as I am this is the link to the other question that I raised: My system isn't reading .XCompose file