Skip to content

Linux compose key: use acute accents and other characters

Posted on:2023-09-24 | 2 min read

I’ve always struggled to configure my English keyboard to use Spanish characters like á, é, í, ó, ú, ñ.

I opted to use English keyboard layout instead of my native Spanish layout because it’s faster to write programming characters {}, [], () using Shift instead of Alt GR.

Before the compose key, I needed to change the keyboard layout to Spanish and use a combination of characters to get the character I mentioned.

I’ve finally dedicated some time to figuring it out, and it was quite easy to configure and use these characters!

Configuring compose key

Here’s my setup:

Depending on your OS/Display Server, you would need to look up your configuration. Let me know if I can help in the comments :).

I’ve set up the right control as the compose key given that my keyboard has limited keys (atreus). I’ve configured my layout “#1” ctrl key to be right ctrl using chrysalis (UI to configure my keyboard).

Command to get the available compose keys:

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

Test your compose key and combinations with this command for the current sway session:

swaymsg 'input * xkb_options compose:rctrl'

Now that you’ve chosen your compose key, use Sway config to set the compose key on startup:

input type:keyboard xkb_options "compose:rctrl"

Using the compose key

Depending on the character you want, you’ll use different compose sequences. Here are the most common ones.

SequenceForSequenceFor
Compose’aáComposeoo°
Compose”aäComposeox¤
Compose`aàComposeoc©
Compose~aãComposeor®
Compose^aâComposeso§
ComposecaǎComposessß
ComposeoaåComposeSS
Compose-aāComposethþ
Compose,aąComposeTHÞ
ComposebaăComposetm
Compose?aCompose??¿
Compose.aȧCompose’<
Compose~nñCompose’>
Compose<sšCompose,cç
Compose|c¢Compose,CÇ
Compose=y¥Compose12½
Compose=cCompose14¼

That’s it! Enjoy using your en_US layout while you also write Spanish, Portuguese, or other languages that make use of acute accents.