You are not logged in.

#1 2024-12-27 01:06:38

esdrasbeleza
Member
Registered: 2009-02-07
Posts: 11

[SOLVED] British keyboard, Portuguese characters

Hello! I hope you're all doing well.

I'm trying to use Linux on an MacBook 2015. It has a British keyboard, I would like to keep my system in English, but since I'm Brazilian I'd like to enable some sequences to type characters in Portuguese. On macOS there's a keyboard layout with the weird name of "Brazilian Pro" that works the way I expect. For example, typing ´ + a should produce an á; ´ + c should produce a ç.

My current desktop is KDE Plasma  6.2.4 on Wayland. During the last days I played with different combinations of layouts, locales, compose configurations etc.

My most successful settings were:
1. Setting the keyboard model to Generic 104-key PC (if I set it to "Apple", it returns the wrong characters for the button on the right of the left Shift key)
2. Setting the keyboard layout to English (UK, Macintosh, intl.). This enables me to type characters with accents, but ç won´t work
3. Creating a ~/.XCompose file with the following content:

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


# Redefine ´ + s to produce 's
<dead_acute> <s> : "'s"

But the results were a bit inconsistent:
- KDE applications work
- WezTerm works
- Firefox won't accept my settings fully: if I type ´ + c, instead of ç of I get a ć; if I type ´ + s, I get 's properly.
- VS Code won't accept my settings at all: if I type ´ + c, instead of ç of I get a ć; if I type ´ + s, I get ś instead of 's.

My questions are:
1. Please, does anybody know how I can use my MacBook with a UK keyboard to type Brazilian characters properly?
2. Is there a user-friendly way to override the combination settings without using a .XCompose file?

Update:

If I change my locale to Brazilian Portuguese, then the keyboard works flawlessly and I can type whatever I want. The problem is that I don't want my desktop to be in Portuguese.
I believe the key here (no pun intended) is to make the keys behave as specified in /usr/share/X11/locale/pt_BR.UTF-8/Compose, but without setting the whole desktop to pt_BR... I just can't make it work.

Last edited by esdrasbeleza (2024-12-27 17:45:13)

Offline

#2 2024-12-27 10:00:11

seth
Member
Registered: 2012-09-03
Posts: 60,768

Re: [SOLVED] British keyboard, Portuguese characters

The input layout generally has nothing to do w/ the output language.
https://wiki.archlinux.org/title/Xorg/K … figuration
Reset the language and post the output of

setxkbmap -print -query

It has a British keyboard

The intl variant of the gb laoyut has dead keys and there's also some  'Clone of the Microsoft "United Kingdom Extended" layout' ("extd") and even a "mac_intl"
Have a look at https://en.wikipedia.org/wiki/QWERTY#English and link the image that looks like the board in front of you.

Offline

#3 2024-12-27 15:09:01

esdrasbeleza
Member
Registered: 2009-02-07
Posts: 11

Re: [SOLVED] British keyboard, Portuguese characters

Hi! Thanks for your answer. Here we go:

setxkbmap output

This is the output for the command you asked; I find it a bit weird that there's no mention for UK or GB even though my layout is set to English (UK, Macintosh, intl.). Maybe it's a Wayland thing.

$ setxkbmap -print -query
WARNING: Running setxkbmap against an Xwayland server
xkb_keymap {
        xkb_keycodes  { include "evdev+aliases(qwerty)" };
        xkb_types     { include "complete"      };
        xkb_compat    { include "complete"      };
        xkb_symbols   { include "pc+us+inet(evdev)"     };
        xkb_geometry  { include "pc(pc105)"     };
};
rules:      evdev
model:      pc105
layout:     us
Keyboard layout

keyboard layout
By Yes0song - Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.p … d=18872239

My keyboard layout is completely fine when I set it to English (UK, Macintosh, intl.) on KDE or GNOME or whatever. Each key, individually, works really well and returns what is expected.
My issue are the key combinations. I can type some accented characters like á or é, but ć is not something I expect for my language.
But I set my locale to en_GB, the combination of ´ + c will print a ć, I expect it to print a ç smile


More Compose stuff

I see that the compose files in /usr/share/X11/locale/<locale>/Compose manage the combinations of which character will be printed if I press a combination of keys. en_US.UTF-8/Compose, for example, has this on line 571:

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

If I open pt_BR.UTF-8/Compose, it has this on line 14:

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

This is the behavior I expect, but if I add those rules to ~/.XCompose I get mixed results.

Offline

#4 2024-12-27 15:22:54

seth
Member
Registered: 2012-09-03
Posts: 60,768

Re: [SOLVED] British keyboard, Portuguese characters

Yeah, that's gb/mac_inlt

My keyboard layout is completely fine when I set it to English (UK, Macintosh, intl.) on KDE or GNOME or whatever. Each key, individually, works really well and returns what is expected.
My issue are the key combinations. I can type some accented characters like á or é, but ć is not something I expect for my language.

Ah, ok - that the IM, not the layout - and not everything uses XIM

Try https://wiki.archlinux.org/title/Input_method#Xim
Don't include the US completion in your ~/.XCompose, pt_BR.UTF-8 incldues that anyway.

FF and electron (VSCODE) will probably use ibus, there's also a "cedilla" IM but electron doesn't seem to like that, https://bbs.archlinux.org/viewtopic.php … 0#p2211650
This might depend on whether you're running on X11 or wayland, though - I'm using chromium on X11 w/ XIM w/o any problems noted so far.

Offline

#5 2024-12-27 17:43:15

esdrasbeleza
Member
Registered: 2009-02-07
Posts: 11

Re: [SOLVED] British keyboard, Portuguese characters

Hah!! It almost worked! But I googled it a bit and used "cedilla" instead of "xim". Now all my apps give me the same expected result. THANK YOU! big_smile

For the case that someone comes here looking for a solution, this is what I done:
1. Set my keyboard layout to "English (UK, Macintosh, intl.)"
2. This is my ~/.XCompose:

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

It impresses me a bit how user-unfriendly this solution was.
Is there a way I can create a new keyboard layout/variant in /usr/share/X11/xkb/symbols in which I can say that ´ + C is a Ç, just like the Compose file does?

Offline

#6 2024-12-27 21:02:24

seth
Member
Registered: 2012-09-03
Posts: 60,768

Re: [SOLVED] British keyboard, Portuguese characters

The composition of dead keys has nothing to do w/ the layout itself, userfriendly or not, but /usr/share/X11/xkb/symbols cannot be used to fix this.
You're essentially looking for the KDE config GUI to add some magic behind the curtain, I can't really speak to this at all, but some recent threads have suggested that this is a common and desired behavior by the relevant locals.

Out of curiosity:
Does dead_acute + s actually generate some accented "s" for /usr/share/X11/locale/pt_BR.UTF-8/Compose ?
Is ~/.XCompose used by the cedilla IM at all?

Offline

#7 2024-12-27 23:59:39

esdrasbeleza
Member
Registered: 2009-02-07
Posts: 11

Re: [SOLVED] British keyboard, Portuguese characters

but some recent threads have suggested that this is a common and desired behavior by the relevant locals.

It's maybe a bit of an edge case, but I'm pretty sure it would prevent some headache for some people. This is a very weird combination of input modules, compose files, keyboard layout etc., when in macOS I just select a keyboard layout. I wonder if a feature like this is something that should be implemented on the desktop environment layer, or some input module, or something else.

Does dead_acute + s actually generate some accented "s" for /usr/share/X11/locale/pt_BR.UTF-8/Compose?

Yes, it does. It generates ś, ḿ etc.
I can type ´ + <space> + s and it would become 's, but typing ´ + s is more convenient. smile

Is ~/.XCompose used by the cedilla IM at all?

It is. If I rename it but keep the GTK/QT IM environment variables, my Ç goes away...

Offline

#8 2024-12-28 07:53:04

seth
Member
Registered: 2012-09-03
Posts: 60,768

Re: [SOLVED] British keyboard, Portuguese characters

Thanks for the head up, you might want to add a paragraph to https://wiki.archlinux.org/title/Locali … gu%C3%AAs) about this

Offline

Board footer

Powered by FluxBB