How do I add user-defined compose key rules in Ubuntu 18.04? I turned my Compose key on using Gnome Tweaks (it's on CapsLock), created a .XCompose
starting with these lines:
include "%L" # import the default Compose file for your locale
# IPA
<Multi_key> <a> <h> : "ɑ"
<Multi_key> <A> <h> : "Ɑ"
# Some more lines
<Multi_key> <ampersand> <underscore> <m> : "̼"
# Math
<Multi_key> <minus> <0> : "−"
<Multi_key> <asterisk> <1> : "⋅"
<Multi_key> <x> <x> : "×"
# ...
I followed this advice, installed uim
and set it as GTK_
and QT_IM_MODULE
but every sequence starting with the <minus> <0>
line gets ignored. When I tried xim
, it did a bit better but it made gedit
glitch:
.
When I tried GTK_IM_MODULE=gtk-im-context-simple
, most of the sequences started working, but some of them just don't.
<Multi_key> <minus> <0> : "−" # doesn't work
<Multi_key> <asterisk> <1> : "⋅" # doesn't work
<Multi_key> <e> <m> <o> <colon> <space> : "?" # works
<Multi_key> <e> <m> <o> <colon> <Up> : "?" # works
<Multi_key> <e> <m> <o> <x> <asterisk> <space> : "?" # doesn't work
<Multi_key> <e> <m> <o> <c> <a> <l> <l> : "?" # doesn't work
<Multi_key> <e> <m> <o> <o> <k> : "?" # works
<Multi_key> <w> <t> <f> : "ಠ_ಠ" # doesn't work
<Multi_key> <w> <h> <y> : "ლ(ಠ益ಠლ)" # doesn't work
<Multi_key> <0> <space> : "" # zero-width space doesn't work
.
What should I do to make my Compose key work properly?
The link you point to is basically correct, with a few caveats:
Compose inserts the character corresponding to the first (shortest) match. Suppose
.XCompose
contains the following entries:Attempts to use EN-SPACE or EM-SPACE will never work.
To get Compose to work with GTK, add the following line to
.profile
:Regarding
gtk-im-context-simple
, Jens Mühlenhoff notes (1, 2):There are several possibilities for Gtk+ input method modules.
The im module decides how additional input aside direct key translation is handled in Gtk+.
So the available compose key sequences depend on what im module you are using. (The symbolic X11 name for the compose key is
Multi_key
btw.)The
gtk-query-immodules-3.0
command can be used to show the installed modules and it can also be used to upate the cache (withsudo gtk-query-immodules-3.0 --update-cache
).Sample output:
xim is the traditional X11 Input Method.
ibus is a more modern input method.
There are several input methods that are used for languages which use non-latin scripts / alphabets.
There are two built-in modules that are not listed by the tool, which are:
It is possible to write your own module if you have the necessary programming skills, see the API documentation here:
https://developer.gnome.org/gtk3/stable/GtkIMContext.html#GtkIMContext.description
I found a useful test tool to easily try out input methods:
https://github.com/ibus/ibus/files/1829333/window.py.txt
You can run it like this:
or
etc.