Compose(5)

โœจ Compose(5) โœจ

okay bestie, welcome to the File Formats Manual corner of the libX11 universe ๐Ÿ’– this is your girl's guide to Compose โ€” the X client mappings for multi-key input sequences. yes it's giving keyboard witchcraft, and yes we're gonna make it make sense ๐Ÿงš


๐ŸŒธ NAME ๐ŸŒธ

Compose โ€” X client mappings for multi-key input sequences ๐ŸŽ€


๐Ÿ’… DESCRIPTION ๐Ÿ’…

so here's the vibe: the X library, libX11, ships a lil' input method for characters that your keyboard literally does not have a key for ๐Ÿ˜ญ how? by letting you press a sequence of keystrokes that get smooshed together into one single character. iconic behavior, no cap.

the compose file gets searched for in this exact order, bestie โ€” don't skip steps:

  • If the environment variable $XCOMPOSEFILE is set, its value is used as the name of the Compose file. first come, first served ๐Ÿ‘‘
  • If the user's home directory has a file named .XCompose, it is used as the Compose file. ๐Ÿ 
  • The system provided compose file is used by mapping the locale to a compose file from the list in /usr/share/X11/locale/compose.dir. ๐Ÿ—‚๏ธ

Compose files can use an "include" instruction. this is the part where you get to be lazy in the best way โ€” it lets local modifications be made to existing compose files without including all of the content directly. for example, the system's iso8859-1 compose file can be included with a line like this:

include "%S/iso8859-1/Compose"

and there are several substitutions that can be made in the file name of the include instruction, so pay attention ๐Ÿ’…:

  • %H expands to the user's home directory (the $HOME environment variable)
  • %L expands to the name of the locale specific Compose file (i.e., "/usr/share/X11/locale/<localename>/Compose")
  • %S expands to the name of the system directory for Compose files (i.e., "/usr/share/X11/locale")

for example, you can include in your compose file the default Compose file by using:

include "%L"

and then rewrite only the few rules that you need to change. New compose rules can be added, and previous ones replaced. lowkey the most powerful little line in the whole file fr fr โœจ


๐Ÿฆ‹ FILE FORMAT ๐Ÿฆ‹

Compose files are plain text files, with a separate line for each compose sequence. Comments begin with # characters. Each compose sequence specifies one or more events and a resulting input sequence, with an optional comment at the end of the line:

EVENT [EVENT...] : RESULT [# COMMENT]

Each event consists of a specified input keysym, and optional modifier states:

[([!] ([~] MODIFIER)...) | None] <keysym>

okay so the modifier tea โ˜•:

  • If the modifier list is preceded by "!" it must match exactly. no vibes-based leniency, she's strict ๐Ÿ’€
  • MODIFIER may be one of Ctrl, Lock, Caps, Shift, Alt or Meta.
  • Each modifier may be preceded by a "~" character to indicate that the modifier must not be present. ๐Ÿ™…
  • If "None" is specified, no modifier may be present.

The result specifies a string, keysym, or both, that the X client receives as input when the sequence of events is input:

"STRING" | keysym | "STRING" keysym

Keysyms are specified without the XK_ prefix. important, don't add it, she will not recognize it ๐Ÿซถ

Strings may be direct text encoded in the locale for which the compose file is to be used, or an escaped octal or hexadecimal character code. Octal codes are specified as "\123" and hexadecimal codes as "\x3a". It is not necessary to specify in the right part of a rule a locale encoded string in addition to the keysym name. If the string is omitted, Xlib figures it out from the keysym according to the current locale. I.e., if a rule looks like:

<dead_grave> <A> : "\300" Agrave

the result of the composition is always the letter with the "\300" code. But if the rule is:

<dead_grave> <A> : Agrave

the result depends on how Agrave is mapped in the current locale. same keystrokes, different energy depending on your locale, the way that works is so real ๐Ÿ˜ญ


๐ŸŒˆ ENVIRONMENT ๐ŸŒˆ

  • XCOMPOSEFILE โ€” File to use for compose sequences.
  • XCOMPOSECACHE โ€” Directory to use for caching compiled compose files. ๐Ÿ—ƒ๏ธ

๐ŸŽ€ FILES ๐ŸŽ€

  • $HOME/.XCompose โ€” User default compose file if XCOMPOSEFILE is not set.
  • /usr/share/X11/locale/compose.dir โ€” File listing the compose file path to use for each locale.
  • /usr/share/X11/locale/<localemapping>/Compose โ€” System default compose file for the locale, mapped via compose.dir.
  • /var/cache/libx11/compose/ โ€” System-wide cache directory for compiled compose files.
  • $HOME/.compose-cache/ โ€” Per-user cache directory for compiled compose files. ๐Ÿ โœจ

๐Ÿ”ฅ SEE ALSO ๐Ÿ”ฅ

XLookupString(3), XmbLookupString(3), XwcLookupString(3), Xutf8LookupString(3), mkcomposecache(1), locale(7).

Xlib - C Language X Interface


and that's the whole page bestie, you ate it ๐Ÿ’…๐ŸŒธ go forth and compose your little multi-key masterpieces, main character energy only. this was X Version 11, libX11 1.8.13 โ€” mwah, see you in the next manpage, ily ๐Ÿซถ๐Ÿ’–

๐Ÿ“ฆ where this page comes from