Compose(5)

๐Ÿ’… Compose(5) โ€” the X client mapping glow-up ๐ŸŽ€

okay so bestie, gather round, because this is the manual page for Compose from the File Formats Manual section (section 5, iykyk), and it's genuinely iconic once you get it. It's all about "X client mappings for multi-key input sequences" โ€” like, the receipts for how your keyboard pulls off the fancy-character magic โœจ


๐ŸŒธ NAME ๐ŸŒธ

Compose โ€” X client mappings for multi-key input sequences. literally that's the whole vibe. ๐Ÿฆ‹


โœจ DESCRIPTION โœจ

so the X library, libX11, ships a super simple input method for characters that go beyond what's actually printed on your typical keyboard. the way it works is you type a sequence of key strokes and they get combined into one single character. no cap, it's giving chef's kiss. ๐Ÿ’…

the compose file is searched for in this exact order, bestie, don't skip steps:

  • if the environment variable $XCOMPOSEFILE is set, then its value is used as the name of the Compose file. that's the main character right there. ๐Ÿ‘‘
  • if the user's home directory has a file named .XCompose, that's your girl, she gets used as the Compose file.
  • otherwise 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, and honestly this is the slay part โ€” it lets you make local modifications to existing compose files without copy-pasting 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"

there are several substitutions you can make in the file name of the include instruction, and they're all little icons:

  • %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. obsessed. ๐Ÿซถ


๐ŸŽ€ 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 now the caveats, listen up because this is where people mess up:

  • if the modifier list is preceded by "!" it must match exactly. no wiggle room, bestie. ๐Ÿ’€
  • 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. periodt.

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. (yes, drop it. it's a nickname situation. ๐Ÿ™ˆ)

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. ๐ŸŒˆ that's the difference, don't forget it!


๐Ÿฆ‹ ENVIRONMENT ๐Ÿฆ‹

  • XCOMPOSEFILE โ€” File to use for compose sequences. your pick, your rules. ๐Ÿ’–
  • XCOMPOSECACHE โ€” Directory to use for caching compiled compose files. it's giving efficiency. โšก

๐ŸŒŸ 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 ๐Ÿ”ฅ


quick vibe check before you go: everything above is exactly as the page says it, so don't come for me if you skip the "!" exact-match rule and your compose breaks. read the caveats, bestie. ๐Ÿ˜ญ๐Ÿ’œ

and that's the whole page, you ate that ๐Ÿ“ โ€” this was X Version 11, libX11 1.8.14, dated with the Compose(5) manual page. mwah, go forth and compose your little hearts out ๐Ÿ’–โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from