Score:3

How to make the keyboard of a MacBook Pro (13-inch, Mid 2012) work right to type in Brazilian Portuguese?

us flag

I installed Ubuntu 22.04.1 inside a mid 2012 MacBook Pro in an attempt to refurbish it and it's working great, I'm taking more advantage of the graphics part just to mention an example.

But I have a problem. I can't get the keyboard to work right while typing in Brazilian Portuguese in other windows other then the Firefox Brownser. xD I tried many combinations inside the keyboard settings via graphic interface withouth sucess. One of the issues is that don't know how to save different "Alternate Charachters Key" and "Compose Keys". When I close the dialogs for these options they return to "None" and "Layout default" even though I choose other options.

I managed to make the keyboard work partially (just inside Firefox, I don't know why) by choosing "Portuguse (Macintosh)" and running the following command:

setxkbmap -model abnt2 -layout us -variant intl

Does anybody knows how can I "extend" this command to affect other windows such as the Terminal or Text Editor for example?

I'm attaching a picture of the Keyboard as a reference for this question:

keyboard of a MacBook Pro (13-inch, Mid 2012)

Here is the hardware specifications for this machine:


MacBook Pro (13-inch, Mid 2012)

Processor 2,9 GHz Dual-Core Intel Core i7

Memory 16 GB 1600 MHz DDR3

Graphics Intel HD Graphics 4000 1536 MB


Below is the result I got if I execute ls -al .config/dconf :


total 16

drwx------  2 chicortiz chicortiz 4096 dez 22 12:02 .

drwx------ 14 chicortiz chicortiz 4096 dez 21 22:04 ..

-rw-rw-r--  1 chicortiz chicortiz 6344 dez 22 12:02 user

EDIT:

Part of the reply:

Screenshot: final setup inside the graphics interface:

final setup inside the graphics interface

chicOrtiz avatar
us flag
Hi Gunnar! I prompted the command " gnome-control-center keyboard " inside the terminal and that sumoned the Graphical Interface for Keyboard Settings. If I try to change "Alternate Characters Key" It's not possible. If I try to change Compose Key it is possible. There is no error messages in the terminal.
Gunnar Hjalmarsson avatar
uz flag
I think you found a bug in that UI. For me it does work to explicitly set the "Alternate Characters Key", but the UI incorrectly says "None". I'll look at that later. (Please note that the **English (US, intl., with dead keys)** keyboard layout defines Right Alt as that Alternate... key by default. So maybe you don't need to change that.)
chicOrtiz avatar
us flag
Ok... I think I got it... This keyboard of mine is not a "Portuguese Machintosh" it is a English (US, intl., with dead keys). If someone set Right Alt as Alternate Characters Key and Left Alt as Compose Key in the graphics interface the keyboard works just fine and this person can write in Brazilian Portuguese. But I also summoned "sudo dpkg-reconfigure keyboard-configuration" so... Do you know if there is a way to print what is saved via "sudo dpkg-reconfigure keyboard-configuration" here? That way I can paste the print in here so we can refine the answer ;)
Gunnar Hjalmarsson avatar
uz flag
FYI I reported the bug in the UI: https://gitlab.gnome.org/GNOME/gnome-control-center/-/merge_requests/910#note_1625253
chicOrtiz avatar
us flag
Other useful commands in this context: $ cat /etc/default/keybord And $ gnome-control-center keyboard
Gunnar Hjalmarsson avatar
uz flag
The bug in the Alternate Characters Key UI, which we found through your question, has now been fixed in Ubuntu 22.04.
chicOrtiz avatar
us flag
That's nice! I'm very glad about that! :)
chicOrtiz avatar
us flag
Looks like the bug returned in the last updates made by the Software Updater. At the moment I need to sumon " setxkbmap -model abnt2 -layout us -variant intl" in every session to make the keyboard work as intended.
Gunnar Hjalmarsson avatar
uz flag
It's unlikely that the UI bug returned. If you have new problems, you'd better ask a new question.
chicOrtiz avatar
us flag
Interesting... For some reason the system added another input source automatically (Portuguese Brazilian) in the graphics interface. Removed that, removed the problem. Ubuntu 22.04.2 LTS By the Way.
Score:1
uz flag

To make the equivalent of

setxkbmap -model abnt2 -layout us -variant intl

effective for the whole system, you need to edit the /etc/default/keyboard file. There is a terminal command for the purpose:

sudo dpkg-reconfigure keyboard-configuration

I'd suggest that you try that, and then reboot.

Edit:

This is the contents of the file that the OP ended up with:

# KEYBOARD CONFIGURATION FILE
# Consult the keyboard(5) manual page.
XKBMODEL="apple_laptop"
XKBLAYOUT="us"
XKBVARIANT="altgr-intl"
XKBOPTIONS=""
BACKSPACE="guess"

My comments:

  • The altgr-intl variant differs from intl. Which one is best is of course a matter of taste.
  • It looks like there is no abnt2 model available in XKB. abnt2 is simply the layout you get by default if you choose XKBLAYOUT="br" instead.
chicOrtiz avatar
us flag
I would like also to thank @Mauricio Valerini O. for pointing out that this keyboard was an English International US keyboard. https://askubuntu.com/users/1659542/mauricio-valerini-o
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.