Compose settings for entering non-standard characters

When typing texts is often necessary to use characters that are not present in your layout, or not presen on keyboard at all. For example, typing something like ¼ or ‰ is a non-trivial task. Of course, you can use a character table and just copy everything from there. But it is good when the desired character is entered 1-2 times. And what to do if you need it constantly? This is where the Compose key comes to the rescue.

 

The compose key is also known as "Multi_key" at the X Window System. In X.Org Server, many keyboard layouts provide different options for the location Multi_key, commonly used in PC-compatible architectures.

You can assign this key in different way. For example, using XkbOptions ("compose: rwin"). In my Kubuntu it can be done in Kmenu-Computer-System Settings-country/region/language. I assigned a button to the Compose key that I never use - CapsLock.

Now let's go through the settings step by step

1. Customize the input method.

Compose requires that the input method be xim
Execute the command:

$ im-switch -c

You will see something like:

There are 10 candidates which provide IM for /home/yakim/.xinput.d/uk_UA:

Selection Alternative

-----------------------------------------------

1 default

*+ 2 default-xim

3 ibus-kde

4 lo-gtk

5 none

6 scim

7 scim-bridge

8 scim-immodule

9 th-gtk

10 th-xim

System wide default for uk_UA (or all_ALL) locale is marked with [+].

Press enter to keep the current selection[*], or type selection number:

Choose default-xim (if it is already installed - we do not change anything)

 

2. Add environment variables

Open the file ~/.bachrc for editing

$ nano ~/.bachrc

And insert two lines there:

export GTK_IM_MODULE=xim

export QT_IM_MODULE=xim

 

3. Let's create a .XСompose file

    $ touch ~/.XСompose

In this file we will store our personal settings for entering additional characters.
You can also edit the system file /usr/share/X11/locale/en_US.UTF-8/Compose, but here are two nuances - firstly, it will not be possible to set individual settings for each user, and secondly, when the system is updated, it is likely that this file will be overwritten and we will lose everything.

 

4. Preparatory work is now complete and you can make our personal input settings.

Open the .XCompose file for editing

$nano ~/.XCompose

The first line is must be:

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

 

If not, all system-wide settings shortcut for us will be lost.

Then start typing your own combination.
For example, I always wanted the apostrophe in the Ukrainian layout to be typed with the same key as in English.

So I'm adding a line:

 

<Multi_key> <Ukrainian_ie> <Ukrainian_ie> : "'"

I also don't like that the $ sign is lost when I switch to Russian or Ukrainian layout. For what would fix it - I add another position:

<Multi_key> <4> <4> : "$"

Save the file and relogin. The keyboard shortcuts we have installed will now work.
For testing, let's launch kate, for example, and then press 3 buttons - the one we selected as Compose key and twice "4". We see that the sign $ appears. Everything worked.

By the way, you can create a whole row of keys at once. For example:

<Multi_key> <a> <z> : "Hello!"

And finally, a small table of standard Compose settings on the system:

Unicode

Символ

Compose

U00a1

¡

"!!"

U00a2

¢

"|c" "c|" "c/" "/c"

U00a3

£

"L-" "-L"

U00a5

¥

"Y=" "=Y"

U00a9

©

"oc" "oC" "Oc" "OC"

U00ab

«

"<<"

U00ae

®

"or" "oR" "Or" "OR"

U00b0

°

"oo"

U00b1

±

"+-"

U00b2

²

"^2"

U00b3

³

"^3"

U00b5

µ

"mu"

U00bb

»

">>"

U00bc

¼

"14"

U00bd

½

"12"

U00be

¾

"34"

U00bf

¿

"??"

U00c2

Â

"^A"

U00c3

Ã

"~A"

U00c4

Ä

""A"

U00c5

Å

"oA"

U00c6

Æ

"AE"

U00df

ß

"ss"

U00f7

÷

":-" "-:"

U2030

"%o"

U20a3

"Fr"

U20a4

"L=" "=L"

At first, these combinations should suffice, and then ...

You can always either Google or carefully read the /usr/share/X11/locale/en_US.UTF-8/Compose file. It describes all combinations