Some notes on entering unusual characters in various X applications

December 30, 2015

Once upon a time it was perfectly fine to only type plain ASCII. But these days even people writing in English (like me) have a steadily increasing desire to occasionally write with accented characters, special symbols like right arrows, and so on. As it happens you can do this in X, although how is not entirely easy and natural unless (and until) you do it a lot.

The first thing you want to do is to make some key your Compose key. If you have a Windows key or two on your keyboard, they make a handy donor key for this purpose and you can set this up with setxkbmap:

setxkbmap -option compose:rwin

This makes my right Windows key into a Compose key.

The basic use of the Compose key is to either tap or hold it and then enter a two-character sequence to get some unusual character. You might ask 'what two-character sequence gets what', and that is a good question. X being X, and Gnome being Gnome, people have made this complicated.

For normal X applications, which I believe includes KDE applications, all of the available key sequences are defined in a Compose file. The standard default file is /usr/share/X11/locale/<locale>/Compose, where the locale is, for example, en_US.UTF-8. You can also have a personal version of this file as $HOME/.XCompose, which may be useful if you want to add additional characters or shuffle things to be more useful. One example of this is this Github repo. Wikipedia also has a guide of common compose combinations.

As covered in the Ubuntu wiki page on the Compose key, GTK-based applications are gratuitously different by defaulting to a hard-coded list that is derived from some version of the default X Compose file. This is probably going to be the same for most common keys, but obviously it'll differ if you have a custom .XCompose file. You can apparently force GTK to use the normal X mechanism if you want, although I haven't tried this.

One advantage of sticking with the default GTK setup is that GTK will then let you directly enter Unicode code points. How this is done is described on the Ubuntu wiki page, although not all GTK applications in all environments will display any indication that this entry mode is active. Having tested it, I can say that this works in Firefox and in gnome-terminal. Unfortunately this is GTK only; it doesn't work in KDE or in general X applications, although there is an upstream bug on this. Don't hold your breath, though.

(Some X applications may have specific support for Unicode code entry and other frills, but you'll have to check their documentation and then maybe experiment to see if it works for you or if it clashes with some other part of your environment.)

Given the GTK situation, my conclusion is that I don't want to bother trying to customize a Compose file for my own use. If I do start wanting unusual special characters on a regular basis (and thus a custom .XCompose), I expect I'll force GTK to use the standard X mechanism and live without the ability to enter Unicode code points. Since I didn't know about it until recently and haven't actually used it, I doubt I'll miss it very much.

(See also this and this.)

Written on 30 December 2015.
« Take notes when (and as) you do things and keep them
How I've wound up taking my notes »

Page tools: View Source, Add Comment.
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Wed Dec 30 03:05:42 2015
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.