A nicer syntax for .XCompose files
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
rockspec
src
.gitignore
.hgtags
LICENSE
README.md

README.md

xcomposer

A nicer syntax for .XCompose files

The Compose key

There are two main ways in Linux to type special characters like λ and . The first is to use the AltGr modifier key. For example, in my computer, typing AltGr+S results in §.

The second way is to use a Compose Key. The Compose Key allows you to type a sequence of keys to generate a character. For example, in my system you can also type § via Compose s o. Compose keys allow you to type many characters that cannot be typed with AltGr and often involve easier to remember mnemonics.

Note that when using the compose key you type the keys one after the other. When using AltGr you press the keys at the same time.

Enabling the Compose key

Keyboards don't typically come with a dedicated Compose key, so it is likely that you may need to configure your system to remap another key to the Compose. In my system I remapped the right Windows key to act as Compose.

The appropriate way to do this remap will depend on the desktop environment you are using. In XFCE this setting can be found under Settings > Keyboard > Layout

Configuring the Compose key

The default behavior of the Compose key (as well as other "dead-key" combinations such as ´+a=á) is locale-specific and is described in /usr/share/X11/locale/<mylocale>/Compose. Most of these Compose files use compose rules from /usr/share/X11/locale/en_US.UTF-8/Compose with small modifications.

It is also possible to define custom Compose rules. For example, in my thesis I use the "long right arrow" , which can't be easily typed using the default compose rules so I made a special compose sequence for it (Compose - - > space). These rules go in a .XCompose file in your home folder but they are cumbersome to write, which is where xcomposer comes in.

Making sure your system respects the .XCompose file

The ibus input system that is used by default in many Linux distributions does not respect the customizations present in the .XCompose file. You might to use a different input method or revert to the xim method. You can do this by setting the following environment variables in your X initialization (.xsessionrc)

export GTK_IM_MODULE="xim"
export QT_IM_MODULE="xim"

Installing xcomposer

The easiest way to install xcomposer is via Luarocks

luarocks install xcomposer

Using xcomposer

xcomposer takes as input a rule file containing a description of your custom Compose rules and creates a suitable .XCompose file for you. You can invoke xcomposer as follows:

xcomposer myrules.xcompose

Passing - as the input file will read rules from the standard input

xcomposer - < myrules.xcompose

By default xcomposer writes its output to $HOME/.XCompose you can override this with the -o flag

xcomposer myrules.xcompose -o out.txt

You can also use -o - to output to standard output.

The xcomposer rule file

My personal xcomposer rule file can be found in the "examples" folder.