Typing Portuguese Accents on a UK Mac Keyboard in Arch Linux

I use Arch Linux with KDE Plasma (6.2.4) on a 2015 MacBook with a UK Mac keyboard. I wanted to type Portuguese accents (like á, ç, õ) while keeping my system language in English. On macOS, the “Brazilian Pro” layout, changed to “Brazilian” in newer versions, made this easy. But in Linux, it took some tweaking.

What didn’t work

My first choice was to try to find something similar to the layout I was using on macOS. Using the UK Macintosh Intl. layout gave me dead keys, but not all combinations worked. For example, ´ + c gave me ć, not ç.

I tried combining English and Portuguese compose files in ~/.XCompose, but results were inconsistent across apps like Firefox and VS Code.

What kind of worked

Using the UK Macintosh Intl. layout and setting my desktop language to Brazilian Portuguese worked. Changing the language would set different compose rules.

en_US.UTF-8/Compose, for example, had this line:`

<dead_acute> <c>			: "ć"	U0107 # LATIN SMALL LETTER C WITH ACUTE

While pt_BR.UTF-8/Compose has these rules:

<dead_acute> <c>      : "ç" ccedilla  # LATIN SMALL LETTER C WITH CEDILLA

What finally worked

The graphic interface on Linux uses a mix of stuff to make your keyboard work, and it seems there’s no user-friendly way to set that. Here’s what I had to do to get it done:

  1. Set my keyboard layout to English (UK, Macintosh, intl.). It can be easily done using your desktop environment settings. Here’s where I set it on KDE. Ops, they call it Plasma nowadays.

    Setting the keyboard input on KDE

  2. Added this to my ~/.XCompose file. These settings make the key combinations for cedilla work, and also allow us to type ' + s to get 's, which is very used in English, without having to type ' + space + s.

    include "/usr/share/X11/locale/pt_BR.UTF-8/Compose"

    <dead_acute> <s> : "'s"
    <dead_acute> <S> : "'S"
    <dead_acute> <t> : "'t"
    <dead_acute> <T> : "'T"
  3. Added this to ~/.config/environment.d/im.conf:

    GTK_IM_MODULE=cedilla
    QT_IM_MODULE=cedilla
    These lines will fix the inconsistent cedilla behaviour across applications.

Links

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.