Saturday, April 30, 2016

Getting Custom Compose Key Sequences to Work in Debian: The Odyssey

Having just spent a very frustrating afternoon trying to get custom compose key sequences working on my new Debian install, I figured I would write a quick post to help others who might be in the same boat.

(For those who don't know, the compose key is a metonym for a fabulous system in Linux that lets you easily type thousands of symbols not found on keyboards. It usually has to be enabled in keyboard settings and can be set to a wide number of keys, but usually the right Windows or Alt keys are popular. Once you have it enabled, you can simply type <Compose Key>-^-a to get â. Or <Compose Key>-"-o to get ö. Or <Compose Key>-o-c to get ©, and so on and so on. There are typically hundreds or thousands of such combinations available by default, ranging from letters from common and uncommon languages to all sorts of esoteric symbols and punctuation [such as the interrobang, ‽, Compose Key-!-?]. Many of them are set up with key combinations that sort of make sense based on the component parts so it's often easy to guess without needing to specifically remember all the combinations. However, I digress.)

This all started with my desire to type some Hawaiian this afternoon, and for that I needed an ʻokina, the letter ‘ʻ’ at the start of the word ʻokina (which is not a quotation mark, despite how it looks; it's Unicode symbol U+02BB, “MODIFIER LETTER TURNED COMMA” [‽]). This is one symbol that isn't in the extensive list of default compose key sequences, but it's not too difficult to add your own—by default in Linux Mint Debian Edition (and I'm guessing plain Debian) there's a file in your home directory called .XCompose where you can simply look at the syntax of all the other entries and define your own sequence based on that.

This file came over in my transfer to Debian, and from what I could find it was what you used to define custom compose key sequences there too, but my sequence I'd added to print an ʻokina in LMDE simply wasn't working, nor were any of the additional ones I created as further tests. (Testing is pretty simple because the .XCompose file is read by programs each time they start up, so you can make a change, re-open a terminal or another text editor, and immediately try it out.)

From some more Googling and reading around, I found the suggestion to add the phrase
export GTK_IM_MODULE=xim # Warning, see below.
to my .profile file in my home directory. Now I'm not super-clear on what all of this means myself, but as best I can tell IM refers to “input method,” and xim refers to an older and more limited input method used by the X server that handles graphical things on Linux. GTK is a toolkit (bunch of code) for making graphical user interfaces that underlies quite a lot of software, along with another toolkit, Qt, and they apparently both have their own internal input methods that seem to not allow custom compose key sequences.

Anyway, what I'm actually trying to say here, is that the above code does not appear to work anymore, although it apparently did in the past. With it in place my custom compose sequence no longer beeped at me angrily like it did before, but simply silently failed with no output. After several hours of following comments in Stack Trace and nearly a score of reboots and reloggings in a futile effort to get things to work, I finally chanced upon a comment suggesting the use of “uim” instead of “xim” (‘u’ for ‘universal;’ I think it's a newer input mode with more functionality). This finally worked for me so I've added the following lines to my .profile file (I added the QT one for completeness, though I don't know how necessary it really is):
export GTK_IM_MODULE=uim
export QT_IM_MODULE=uim
Once you've done that, you'll need to make sure you have the actual uim package installed; on Debian, run
$ sudo apt-get install uim
Once you've done that, log out and log back in and things should hopefully work now. Hope that helps! As for me:

◦ Confounding compose key conundrum: cracked!

No comments:

Post a Comment

Think I said something interesting or insightful? Let me know what you thought! Or even just drop in and say "hi" once in a while - I always enjoy reading comments.