X Compose Key (type characters that are not available directly on the keyboard)

Page created: 2023-05-04

How do you type a German 'ß' ("sharp S") on an ANSI keyboard with a layout containing only unaccented Latin characters?

The standard answer for X Window System users is: The compose key (wikipedia.org).

In Slackware, no compose key is set by default, as you can see from the empty output in this search:

$ setxkbmap -print -verbose 10 | grep compose
<nothing>

To see which keys are available to be set as the compose key, search for them in this X11 rules file:

$ grep compose: /usr/share/X11/xkb/rules/base.lst

Having chosen a key, try it out by setting the option for the current X session. I chose the right Alt key:

setxkbmap -option compose:ralt

We can confirm it’s been set with the search:

$ setxkbmap -print -verbose 10 | grep compose
options:    compose:ralt,terminate:ctrl_alt_bksp
symbols:    pc+us+inet(evdev)+compose(ralt)+terminate(ctrl_alt_bksp)
    xkb_symbols   { include "pc+us+inet(evdev)+compose(ralt)+terminate(ctrl_alt_bksp)"  };

And sure enough, it works. Here, I’ve typed Alt s s (pressing and releasing Alt and then typing S twice):

Ich heiße Dave.

To make it permanent, stick the setxkbmap in your .xinitrc or equivalent.

# Set the right Alt key as the compose key:
setxkbmap -option compose:ralt

To see the whole list of compose character possibilities, find the Compose file for your locale:

$ locale | grep LANG
LANG=en_US.UTF-8

$ head /usr/share/X11/locale/en_US.UTF-8/Compose
# UTF-8 (Unicode) compose sequence
# David.Monniaux@ens.fr
#
# Part 1 - Manual definitions
# Spacing versions of dead accents
<dead_tilde> <space>                : "~"   asciitilde # TILDE
<dead_tilde> <dead_tilde>           : "~"   asciitilde # TILDE
<dead_acute> <space>                : "'"   apostrophe # APOSTROPHE
<dead_acute> <dead_acute>           : "´"   acute # ACUTE ACCENT
<Multi_key> <apostrophe> <apostrophe>   : "´"   acute # ACUTE ACCENT
...

The mnemonics are quite well chosen, including these clever and memorable character sequences:

<Multi_key> <less> <3>          : "♥"    U2665 # BLACK HEART SUIT

<Multi_key> <colon> <parenright>    : "☺"    U263A # WHITE SMILING FACE
<Multi_key> <colon> <parenleft>     : "☹"    U2639 # WHITE FROWNING FACE
<Multi_key> <backslash> <o> <slash> : "🙌" U1F64C # PERSON RAISING BOTH HANDS IN CELEBRATION

<Multi_key> <p> <o> <o>         : "💩"  U1F4A9 # PILE OF POO

<Multi_key> <F> <U>         : "🖕" U1F595 # REVERSED HAND WITH MIDDLE FINGER EXTENDED
<Multi_key> <L> <L> <A> <P>     : "🖖" U1F596 # RAISED HAND WITH PART BETWEEN MIDDLE AND RING FINGERS

I got a good chuckle out of these.