Skip to content

Instantly share code, notes, and snippets.

@victoroliveirab
Created September 20, 2021 14:11
Show Gist options
  • Save victoroliveirab/181b6efed08597752a891ec1cb5f3f5d to your computer and use it in GitHub Desktop.
Save victoroliveirab/181b6efed08597752a891ec1cb5f3f5d to your computer and use it in GitHub Desktop.
K2 Brazilian Keymap
// Add below to /usr/share/X11/xkb/symbols/br in replacement of Brazilian Nativo layout for US keyboards
//
// Keychron K2 Brazilian - Replaces Brazilian Nativo layout for US keyboards.
//
// Victor Oliveira <eu@victoroliveira.com.br>
//
partial alphanumeric_keys
xkb_symbols "nativo-us" {
include "br(nativo)"
name[Group1]="Portuguese (Brazil, Nativo for US keyboards)";
key <TLDE> { [ grave, dead_tilde, notsign, notsign ] };
key <AE01> { [ 1, exclam, onesuperior, 1] };
key <AE02> { [ 2, at, twosuperior, onehalf ] };
key <AE03> { [ 3, numbersign, threesuperior, threequarters ] };
key <AE04> { [ 4, dollar, sterling, onequarter ] };
key <AE05> { [ 5, percent, cent, threeeighths ] };
key <AE06> { [ 6, dead_circumflex, notsign, diaeresis ] };
key <AE07> { [ 7, ampersand ] };
key <AE08> { [ 8, asterisk ] };
key <AE09> { [ 9, parenleft ] };
key <AE10> { [ 0, parenright ] };
key <AE11> { [ minus, underscore ] };
key <AE12> { [ equal, plus, section, dead_ogonek ] };
key <AD01> { [ q, Q, slash, slash ] };
key <AD02> { [ w, W, question, question ] };
key <AD03> { [ e, E, degree, degree ] };
key <AD04> { [ r, R, registered, registered ] };
key <AD05> { [ t, T ] };
key <AD06> { [ y, Y ] };
key <AD07> { [ u, U ] };
key <AD08> { [ i, I ] };
key <AD09> { [ o, O, degree ] };
key <AD10> { [ p, P ] };
key <AD11> { [ bracketleft, braceleft, ordfeminine, dead_macron ] };
key <AD12> { [ bracketright, braceright, masculine, masculine ] };
key <AC01> { [ a, A ] };
key <AC02> { [ s, S ] };
key <AC03> { [ d, D ] };
key <AC04> { [ f, F ] };
key <AC05> { [ g, G ] };
key <AC06> { [ h, H ] };
key <AC07> { [ j, J ] };
key <AC08> { [ k, K ] };
key <AC09> { [ l, L ] };
key <AC10> { [ semicolon, colon ] };
key <AC11> { [ dead_acute, quotedbl ] };
key <AC12> { [ backslash, bar ] };
key <BKSL> { [ backslash, bar ] };
key <AB01> { [ z, Z ] };
key <AB02> { [ x, X ] };
key <AB03> { [ c, C, ccedilla, CCedilla ]};
key <AB04> { [ v, V ] };
key <AB05> { [ b, B ] };
key <AB06> { [ n, N ] };
key <AB07> { [ m, M ] };
key <AB08> { [ comma, less ] };
key <AB09> { [ period, greater ] };
key <AB10> { [ slash, question, questiondown ] };
};
@victoroliveirab
Copy link
Author

If this doesn't work:

It's because the cedilla module isn't loaded by default when the locale is set to en, so you have to change the configuration files for gtk to add them:

  1. Edit configuration files:
sudo vim /usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules.cache

sudo vim /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules.cache

On both, find the lines starting with "cedilla" "Cedilla" and add :en to the line. Something like this:

"cedilla" "Cedilla" "gtk30" "/usr/share/locale" "az:ca:co:fr:gv:oc:pt:sq:tr:wa:en"
  1. Change the Compose file:
sudo sed -i /usr/share/X11/locale/en_US.UTF-8/Compose -e 's/ć/ç/g' -e 's/Ć/Ç/g'
  1. Instruct the system to load the cedilla module:

Add those lines to /etc/environment:

GTK_IM_MODULE=cedilla
QT_IM_MODULE=cedilla

Reboot and you are done.

Source: https://superuser.com/a/1235405

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment