How To Customize Your Linux Interface — Part 2

Currency symbolsLast week I explained how to get your keyboard and mouse button layout set up just the way you want them. Along the way I mentioned something called the Compose key. Let’s see what it can do for us!

With last week’s correction and modification of the keyboard layout, we made sure that all the keys are in their proper places. That is, when you press any particular key you get the correct character or other event (like Shift, Control, and so on). I explained that my personal preference was to banish the useless and somewhat dangerous Caps Lock key, showing how to turn that key into another Control key.

So we can remove a key from the layout. What about adding characters that aren’t there?

Adding Linux Special Characters

We can’t add more keys to the keyboard, but we can use the Compose key to enter needed characters as multi-key sequences. You should have a Compose key set up on your keyboard, but it probably doesn’t say “Compose”. We can find it, though.

The easiest way to do this is through the desktop settings of your Gnome or KDE interface, as you have seen in the Linux introduction course. If the desktop settings don’t work for you, run this command:

$ dumpkeys | grep Compose

You are looking for blocks that start like the following, I found these two:

... many lines deleted ...
keycode  99 = Compose          Compose          Compose
... many more lines deleted ...
keycode 127 = Compose          Compose          Compose
... many more lines deleted ...

OK, we need the keys producing keycodes 99 and 127. Now run the showkey command. You probably can’t do this under X as an ordinary user. You might be able to run it under X with sudo or su, or you might find it easier to switch to a text console (with, say, Control-Alt-F2) and run it there.

Try the keys that you don’t usually use. You are looking for the ones that report “keycode 99 press“, or whatever number(s) you are looking for.

For me, 99 is a PrintScreen / SysRQ key, which inconveniently runs the KDE Screenshot tool when I press it under X. But 127 is a heretofore mysterious key next to the unused Windows Start key between the right-side Alt and Shift keys. I have a Microsoft keyboard, this key is meant to be some Windows-specific thing that gets a little picture of what looks like an arrow pointing to the second drawer in a four-drawer filing cabinet. Whatever…

I have found my Compose key, and I certainly wasn’t using that key for anything else! The fact that it has an odd symbol on it just makes it easier for me to remember — To create an unusual character, I use the unusual key. See last week’s blog for how to move Compose somewhere else if you prefer.

Now, what can I do with this key?

You can get some idea with the following command, notice that we’re looking for all lower case now:

dumpkeys | grep compose

Lines like these:

compose '\'' 'E' to 'É'
compose '`' 'e' to 'è'

mean that pressing the 3-key sequence Compose ' E generates the accented character É, while Compose ` e generates è. So, to name the town of Sainte-mère-Église in a text file, you would press this sequence, where I have highlighted the Compose tricks:

S a i n t e - m Compose ` e r e - Compose ' E g l i s e

However, showkeys only shows us a small sample of what is possible! I see nothing in its output about how Compose - L generates the British pound symbol £, but it does.

For an exhaustive list, consult the text file /usr/share/X11/locale/en_US.UTF-8/Compose, change the obvious part to another directory name if you have a different locale.

That file is enormous, so use grep with the -i flag to ignore case:

$ grep -i yen /usr/share/X11/locale/en_US.UTF-8/Compose
<Multi_key> <Y> <equal>         : "Â¥"   yen # YEN SIGN
<Multi_key> <y> <equal>         : "Â¥"   yen # YEN SIGN
<Multi_key> <equal> <Y>         : "Â¥"   yen # YEN SIGN
<Multi_key> <equal> <y>         : "Â¥"   yen # YEN SIGN
<Multi_key> <Y> <minus>         : "Â¥"   yen # YEN SIGN
<Multi_key> <minus> <Y>         : "Â¥"   yen # YEN SIGN
<Multi_key> <y> <minus>         : "Â¥"   yen # YEN SIGN
<Multi_key> <minus> <y>         : "Â¥"   yen # YEN SIGN
<dead_currency> <Y>           : "å"   U5186    # YEN
<dead_currency> <y>           : "Â¥"   yen     # YEN SIGN

With these tools, you can now easily enter this into a text file:

Today, $1.00 is worth £0.65, ¥119.12, or €0.88.

I don’t need these characters very often, but when I do, it’s great that I can generate them with three key presses!

Type to search

Do you mean "" ?

Sorry, no results were found for your query.

Please check your spelling and try your search again.