1. Home
  2. blog
  3. compose-key-linux

The compose key and ~/.XCompose


Motivation

I have recently been looking for ways to type math symbols effortlessly without having to look them up and copy and paste them, such as ∀∃∪∩⇒∈[…].

As an Italian with a US keyboard layout, I had also wondered for some time how to type ‘è’ (and similar letters) without constantly switching layouts.

After some trial and error, I found a solution that works decently (it’s not perfect, see below1): the ~/.XCompose configuration file (https://wiki.debian.org/XCompose).

In the examples below, <Compose> is the compose key, represented as <Multi_key> in ~/.XCompose. It is necessary to set up the <Compose> key binding on your system first. It is easy to do on KDE. I chose the <Menu> key in my setup.

This is my ~/.XCompose configuration. It allows me to type <Compose> \ a l l, which inserts the character ”“.

For Flatpak apps, allow them to read the ~/.XCompose file1:

flatpak override --user --filesystem=~/.XCompose
~/.XCompose
include "%L"

<Multi_key> <backslash> <c> <u> <p> : "∪" U222A
<Multi_key> <backslash> <c> <a> <p> : "∩" U2229

# <Multi_key> <backslash> <f> <o> <r> <a> <l> <l> : "∀" U2200
<Multi_key> <backslash> <f> <o> <r> : "∀" U2200
<Multi_key> <backslash> <a> <l> <l> : "∀" U2200
# <Multi_key> <backslash> <e> <x> <i> <s> <t> <s> : "∃" U2203
<Multi_key> <backslash> <e> <x> : "∃" U2203
<Multi_key> <backslash> <i> <n> : "∈" U220A
<Multi_key> <backslash> <n> <o> <t> <i> <n> : "∉" U2209
<Multi_key> <backslash> <s> <u> <b> <s> <e> <t> : "⊂" U2282
<Multi_key> <backslash> <s> <u> <p> <s> <e> <t> : "⊃" U2283
<Multi_key> <backslash> <e> <m> <p> <t> <y> <s> <e> <t> : "∅" U2205

<Multi_key> <backslash> <a> <n> <d> : "∧" U2227
<Multi_key> <backslash> <o> <r> : "∨" U2228
<Multi_key> <backslash> <n> <o> <t> : "¬" U00AC
<Multi_key> <backslash> <t> <o> : "→" U2192
<Multi_key> <backslash> <i> <m> <p> <l> <i> <e> <s> : "⇒" U21D2
<Multi_key> <backslash> <i> <f> <f> : "⇔" U21D4

# Conflicts with in
# <Multi_key> <backslash> <i> <n> <t> : "∫" U222B
<Multi_key> <backslash> <s> <u> <m> : "∑" U2211
<Multi_key> <backslash> <p> <r> <o> <d> : "∏" U220F
# <Multi_key> <backslash> <i> <n> <f> <t> <y> : "∞" U221E
<Multi_key> <backslash> <n> <a> <b> <l> <a> : "∇" U2207
<Multi_key> <backslash> <p> <a> <r> <t> <i> <a> <l> : "∂" U2202

<Multi_key> <backslash> <p> <m> : "±" U00B1
<Multi_key> <backslash> <m> <p> : "∓" U2213
<Multi_key> <backslash> <t> <i> <m> <e> <s> : "×" U00D7
<Multi_key> <backslash> <d> <i> <v> : "÷" U00F7
<Multi_key> <backslash> <c> <d> <o> <t> : "⋅" U22C5

<Multi_key> <backslash> <n> <e> <q> : "≠" U2260
<Multi_key> <backslash> <l> <e> <q> : "≤" U2264
<Multi_key> <backslash> <g> <e> <q> : "≥" U2265
<Multi_key> <backslash> <a> <p> <p> <r> <o> <x> : "≈" U2248
<Multi_key> <backslash> <e> <q> <u> <i> <v> : "≡" U2261
<Multi_key> <backslash> <p> <r> <o> <p> <o> <r> <t> <i> <o> <n> <a> <l> : "∝" U221D

<Multi_key> <backslash> <a> <l> <p> <h> <a> : "α" U03B1
<Multi_key> <backslash> <b> <e> <t> <a> : "β" U03B2
<Multi_key> <backslash> <g> <a> <m> <m> <a> : "γ" U03B3
<Multi_key> <backslash> <d> <e> <l> <t> <a> : "δ" U03B4
<Multi_key> <backslash> <p> <i> : "π" U03C0
<Multi_key> <backslash> <t> <h> <e> <t> <a> : "θ" U03B8
<Multi_key> <backslash> <l> <a> <m> <b> <d> <a> : "λ" U03BB
<Multi_key> <backslash> <m> <u> : "μ" U03BC
<Multi_key> <backslash> <D> <e> <l> <t> <a> : "Δ" U0394

  1. On some Flatpak apps under Wayland, the custom key bindings are not detected. I remember finding a hacky workaround, probably running the Flatpak apps with XWayland, but it led to some issues and I backtracked.

    Apps like Google Chrome try to hijack the compose key and implement their own version of it, which also does not use this configuration.