Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard layout messed up for KBD_PORTUGUESE_BRAZILIAN_ABNT2. #27

Closed
tb110188 opened this issue Apr 22, 2021 · 96 comments
Closed

Keyboard layout messed up for KBD_PORTUGUESE_BRAZILIAN_ABNT2. #27

tb110188 opened this issue Apr 22, 2021 · 96 comments

Comments

@tb110188
Copy link

When I try to type any text on any of the GUI applicatuins, the letter doesnt matches the keyboard layout (it works just fine from the command prompt).

@hideyukn88
Copy link
Member

@tb110188 , would you please attach weston.log from /mnt/wslg ? and what keyboard layout do you use in Windows side ?

@tb110188
Copy link
Author

@tb110188 , would you please attach weston.log from /mnt/wslg ? and what keyboard layout do you use in Windows side ?

i'm reinstalling Ubuntu... And sure, also I do use PT BR (ABNT2)

@jordan080
Copy link

I'm having the same issue. My keyboard layout is PT-BR (ABNT2) too, and here's my weston.log file:

weston.log

@tb110188
Copy link
Author

@jordan080 Thanks...

@hideyukn88
Copy link
Member

hideyukn88 commented Apr 22, 2021

From your weston.log.

[23:07:28.183] kbd_layout:0x416 kbd_type:0x4 kbd_subType:0x0 kbd_functionKeys:0xc

RDP client is correctly reports 0x416, which is ...

#define KBD_PORTUGUESE_BRAZILIAN_ABNT 0x00000416

Would you please do "setxkbmap -print -verbose 10" on Linux side to see if corresponding layout is installed/configured in Xkb ?

@tb110188
Copy link
Author

Setting verbose level to 10
locale is C
Trying to load rules file ./rules/evdev...
Trying to load rules file /usr/share/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules: evdev
model: pc105
layout: us
Trying to build keymap using the following components:
keycodes: evdev+aliases(qwerty)
types: complete
compat: complete
symbols: pc+us+inet(evdev)
geometry: pc(pc105)
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)" };
};

@tb110188
Copy link
Author

weston.log

also here is my weston.log

@jordan080
Copy link

From your weston.log.

[23:07:28.183] kbd_layout:0x416 kbd_type:0x4 kbd_subType:0x0 kbd_functionKeys:0xc

RDP client is correctly reports 0x416, which is ...

#define KBD_PORTUGUESE_BRAZILIAN_ABNT 0x00000416

Would you please do "setxkbmap -print -verbose 10" on Linux side to see if corresponding layout is installed/configured in Xkb ?

My output from "setxkbmap" is pretty much the same as that of @tb110188:

Setting verbose level to 10
locale is C
Trying to load rules file ./rules/evdev...
Trying to load rules file /usr/share/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules: evdev
model: pc105
layout: us
Trying to build keymap using the following components:
keycodes: evdev+aliases(qwerty)
types: complete
compat: complete
symbols: pc+us+inet(evdev)
geometry: pc(pc105)
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)" };
};

@hideyukn88
Copy link
Member

Assuming you are on Ubuntu, can you configure keyboard layout using "sudo dpkg-reconfigure keyboard-configuration" and restart WSLg by wsl --shutdown or wsl --terminate [distro name] ?

@tb110188
Copy link
Author

tb110188 commented Apr 22, 2021

@hideyukn88 Nope, still the same issue...

@tb110188
Copy link
Author

when I try to type "qwerty" this is what it shows "/,.hxw"...

@tb110188
Copy link
Author

I don't know exactly what i did, i installed full gnome pckages and change my locale to pt_BR.UTF8, also changind some stuff related to the keyboar... and now it's working just fine...

@jordan080
Copy link

I don't know exactly what i did, i installed full gnome pckages and change my locale to pt_BR.UTF8, also changind some stuff related to the keyboar... and now it's working just fine...

What exactly did you change in the keyboard settings? And did you install the full GNOME DE?

@tb110188
Copy link
Author

I don't know exactly what i did, i installed full gnome pckages and change my locale to pt_BR.UTF8, also changind some stuff related to the keyboar... and now it's working just fine...

What exactly did you change in the keyboard settings? And did you install the full GNOME DE?

Tried again, but without installing Full Gnome Desktop Experience...

I think we need that...

@tb110188
Copy link
Author

Update:

We don't need Gnome Desktop Experience, but i don't know what else...

@luishdemetrio
Copy link

luishdemetrio commented Apr 22, 2021

The same here. It only worked here after removing the Brazilian ABTN2 keyboard and have restarted WSL. It is working with United States-International.

@tb110188
Copy link
Author

there shoul be a way to make it work without messing with the keyboard...

@tb110188
Copy link
Author

Unfortunately, while they don't fix it, we won't be able to use GUI apps with ABNT2 keyboards

@PauloCotrim
Copy link

setxkbmap -model abnt2 -layout br -variant abnt2

@tb110188
Copy link
Author

tb110188 commented Apr 23, 2021

Didn't work for me

Did you changed the LOCALE too???

@PauloCotrim
Copy link

setxkbmap -model abnt2 -layout br -variant abnt2
do without restarting wsl. If it works, you will probably have to configure it in .wsl config

@PauloCotrim
Copy link

sudo update-locale LANG=pt_BR.UTF8

@tb110188
Copy link
Author

sudo update-locale LANG=pt_BR.UTF8

*** update-locale: Error: invalid locale settings: LANG=pt_BR.UTF8

@PauloCotrim
Copy link

sudo dpkg-reconfigure locales ?

@PauloCotrim
Copy link

edit sudo vim /etc/locale.gen

@tb110188
Copy link
Author

now we do need aa way to keep this config when we shutdown WSL...

@PauloCotrim
Copy link

echo "setxkbmap -model abnt2 -layout br -variant abnt2" >> ~/.bashrc

I didn't find any parameters in /etc/wsl.conf

so I put it to set when starting bash in the terminal

@tb110188
Copy link
Author

it stops working when i install gnome-terminal... lol

@jordan080
Copy link

Tried all of @PauloCotrim solutions, and none of these work

@tb110188
Copy link
Author

Tried all of @PauloCotrim solutions, and none of these work

first step, configure your locale

sudo dpkg-reconfigure locales

on the screen scroll down and choose pt_BR.UTF8

then next you will do ok and ok, and run this on the command line

sudo update-locale LANG=pt_BR.UTF8

in the end you run this

setxkbmap -model abnt2 -layout br -variant abnt2

and don't restart WSL yet, just try...

@adrian-gierakowski
Copy link

this helped

WAYLAND_DISPLAY="wayland-1"

now the linux gui apps follow the layout selected in windows, however the frames of the windows are kind of ugly. Any idea how to configure this?

@adrian-gierakowski
Copy link

So the WAYLAND_DISPLAY doesn't seem to work anymore :/

Anyway, It seems like the problem in my case is due to the Colemak layout not being recognised.
I've got 4 layouts configured on Window side:

windows-keyboard-layouts

and here's what I see when tailing /mnt/wslg/weston.log while switching between them (from bottom to top):

[10:53:57.413] Client: LanguageImeInfo: ProfileType: 2 (TF_PROFILETYPE_KEYBOARDLAYOUT)
[10:53:57.413] Client: LanguageImeInfo: LanguageID: 0x409
[10:53:57.413] Client: LanguageImeInfo: LanguageProfileCLSID: GUID_NULL
[10:53:57.413] Client: LanguageImeInfo: ProfileGUID: GUID_NULL
[10:53:57.413] Client: LanguageImeInfo: KeyboardLayout: 0x809
[10:53:57.413] convert_rdp_keyboard_to_xkb_rule_names: matching layout=gb variant=(null) options=(null)
[10:53:59.431] Client: LanguageImeInfo: ProfileType: 2 (TF_PROFILETYPE_KEYBOARDLAYOUT)
[10:53:59.431] Client: LanguageImeInfo: LanguageID: 0x809
[10:53:59.431] Client: LanguageImeInfo: LanguageProfileCLSID: GUID_NULL
[10:53:59.431] Client: LanguageImeInfo: ProfileGUID: GUID_NULL
[10:53:59.431] Client: LanguageImeInfo: KeyboardLayout: 0x10409
[10:53:59.431] convert_rdp_keyboard_to_xkb_rule_names: matching layout=us variant=dvorak options=(null)
[10:54:01.172] Client: LanguageImeInfo: ProfileType: 2 (TF_PROFILETYPE_KEYBOARDLAYOUT)
[10:54:01.172] Client: LanguageImeInfo: LanguageID: 0x809
[10:54:01.172] Client: LanguageImeInfo: LanguageProfileCLSID: GUID_NULL
[10:54:01.172] Client: LanguageImeInfo: ProfileGUID: GUID_NULL
[10:54:01.172] Client: LanguageImeInfo: KeyboardLayout: 0x809
[10:54:01.172] convert_rdp_keyboard_to_xkb_rule_names: matching layout=gb variant=(null) options=(null)
[10:54:02.761] Client: LanguageImeInfo: ProfileType: 2 (TF_PROFILETYPE_KEYBOARDLAYOUT)
[10:54:02.761] Client: LanguageImeInfo: LanguageID: 0x809
[10:54:02.761] Client: LanguageImeInfo: LanguageProfileCLSID: GUID_NULL
[10:54:02.761] Client: LanguageImeInfo: ProfileGUID: GUID_NULL
[10:54:02.761] Client: LanguageImeInfo: KeyboardLayout: 0xa0000409
[10:54:02.761] convert_rdp_keyboard_to_xkb_rule_names: matching layout=(null) variant=(null) options=(null)
[10:54:02.761] rail_client_LanguageImeInfo_callback: Failed to switch to kbd_layout:0xa0000409 kbd_type:0x2110110 kbd_subType:0x2

Apart from Colemak not being able to match with anything (matching layout=(null) variant=(null) options=(null)), it's also interesting that the US layout (first from the bottom on the screenshot) is matched with layout=gb variant=(null) options=(null)

I wonder if I need to install the colemak layout on the linux side for it to be able to match the windows one?

@adrian-gierakowski
Copy link

So the WAYLAND_DISPLAY doesn't seem to work anymore :/

ok, I managed to get it working again, when I set WAYLAND_DISPLAY to a non existing display (not present in $XDG_RUNTIME_DIR), I can control the keyboard layout used by GUI applications by running setxkbmap in wsl terminal. So this makes it use the colemak layout (regardless of what's on Windows side):

setxkbmap us -variant colemak

now, when I change layout on windows side it will override the one set with setxkbmap, however I still get the error when switching to colemak on windows side (and need to set it from terminal)

setxkbmap doesn't work with the default WAYLAND_DISPLAY=wayland-0`

@hideyukn88
Copy link
Member

@adrian-gierakowski, thanks for reporting the issue. If I understand correctly, by default, Windows doesn't support "colemak" keyboard layout. Have you installed 3rd party keyboard layout file to Windows? thanks!

@hideyukn88
Copy link
Member

Closing this issue as KBD_PORTUGUESE_BRAZILIAN_ABNT2 should be working correctly. If there is issue with KBD_PORTUGUESE_BRAZILIAN_ABNT2, please reopen this issue. If there is issue with other keyboard layout/language, please open new issue, thanks!

@fred-camargo-cpfl
Copy link

I know that this thread is closed, but I needed to leave this comment, that the only thing that make it work for me, was this post from @baiano , besides:

      setxkbmap -model abnt2 -layout br -variant abnt2

that was suggested a couple of times before, the difference for me was:

     WAYLAND_DISPLAY="wayland-1"

I tried with gedit, and finally, it recognized the ABNT2 keyboard.
Regarding vscode, I don´t have installed it in wsl yet.

@beppler
Copy link

beppler commented Feb 2, 2022

For me it works without display, but only after the first graphical program has been run.

@GPMrks
Copy link

GPMrks commented Feb 11, 2022

Tried all of @PauloCotrim solutions, and none of these work

first step, configure your locale

sudo dpkg-reconfigure locales

on the screen scroll down and choose pt_BR.UTF8

then next you will do ok and ok, and run this on the command line

sudo update-locale LANG=pt_BR.UTF8

in the end you run this

setxkbmap -model abnt2 -layout br -variant abnt2

and don't restart WSL yet, just try...

Thank you so much. This was really annoying to me. And it finally got fixed.

My best wishes.

@robertoalvesneto
Copy link

When I launch 'tilix' or 'guake' by terminal my keyboard settings work fine, i can press 'ç' '~' etc. But my appearance changes, like themes and colors, don't work.
image

When i launch 'tilix' or 'guake' by shortcut on C:\Users\ranen\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Ubuntu-20.04 my keyboard settings don't work, but apprerance changes works:
image

does anyone know why? Maybe it's a silly doubt but I've searched a lot and I haven't found a solution.

@hideyukn88
Copy link
Member

@robertoalvesneto, have you updated WSL with the latest version from aka.ms/wslstorepage? If this doesn't solve, please let me know how those settings (themes, color and keyboard layout) are applied, thanks!

@robertoalvesneto
Copy link

@hideyukn88 thanks for the reply.

Some versions:

PS C:\WINDOWS\system32> wsl --update
Verificando atualizações...
Não há atualizações disponíveis.
Versão do kernel: 5.10.60.1  
C:\Users\ranen>ver
Microsoft Windows [versão 10.0.22000.527]
VcXsrv X Server
version 1.20.9.0

How i set up the theme:

I installed the gnome-tweaks using apt, downloaded the theme from gnome-look, move to folder .themes and launch tweaks by terminal and set new theme. The gnome tweaks alert on terminal:

/mnt/c/Users/ranen ❯ gnome-tweaks
WARNING : Shell not installed or running
WARNING : Shell not running
NoneType: None
WARNING : Error detecting shell
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/gtweak/tweaks/tweak_group_shell_extensions.py", line 217, in __init__
    raise Exception("Shell not running or DBus service not available")
Exception: Shell not running or DBus service not available

If i launch any app by terminal the theme is not applied. But, if i launch by shortcut icon on windows folder the theme is applied.
Conversely, the keyboard work fine in any app launched by terminal, but not through the shortcut icon.

IBus preferences

I try set keyboard in the ibus but it doesn't seem to have any effect, and every time i open it, it alerts:

The IBus daemon is not running. Do you wish to start it?
>y
IBus has been started! if you cannot use IBus, add the following lines to your .bashrc; then relog into your desktop.
export GTK_IM_MODULE=ibus
export XMODIFIERS=@um=ibus
export QT_IM_MODULE=ibus

I add this vars to .bashrc and .zshrc, nothing happened:

@hideyukn88
Copy link
Member

@robertoalvesneto, thanks for detail info, WSL alone doesn't manage keyboard layout, but WSLg does. In your case, VcXsrv is being used instead of WSLg, you might need to follow up with VcXsrv. Thanks!

@robertoalvesneto
Copy link

@hideyukn88 thanks for your answer! I installed VcXsrv a long time ago and i didn't even know WSLg. I uninstalled VcXsrv and updated all. I still have problems but at least they are new problems 😆.
For anyone else who has similar keyboard problems, check three things:

  • What GUI you use;
  • wayland or x11;
  • you launch your apps by bash or zsh;

In my case, change to wayland made the gnome theme work

export GDK_BACKEND=wayland

For my, run source ~/.zshrc was not enough, it gave an error of DISPLAY :0, so, try reboot your wsl.

And launch my apps by bash instead of zsh made my keyboard language work.

I still don't know how to make the keyboard preferences work by launching the app from zsh, but I've made some progress.

References that helped me:

reddit WSLg vs VcXsrv
Context menu doesn't respect screen bounds #641

@gmazoni
Copy link

gmazoni commented Apr 22, 2022

This is how I persist the configuration with /etc/wsl.conf

[user]
default=guilherme

[boot]
command="export WAYLAND_DISPLAY='wayland-1' && setxkbmap -model abnt2 -layout br -variant abnt2"

@hideyukn88
Copy link
Member

@gmazoni, do you still see the issue (without applying your workaround) even using the latest WSL from aka.ms/wslstorepage? thanks!

@gmazoni
Copy link

gmazoni commented Apr 22, 2022

@gmazoni, do you still see the issue (without applying your workaround) even using the latest WSL from aka.ms/wslstorepage? thanks!

Hi @hideyukn88, thanks for replying, I updated the WSL and it solved my problem, I removed the wsl.conf and checked all my rc profiles to not export and execute setxkbmap.

@thomassalmeida
Copy link

Tried all of @PauloCotrim solutions, and none of these work

first step, configure your locale

sudo dpkg-reconfigure locales

on the screen scroll down and choose pt_BR.UTF8

then next you will do ok and ok, and run this on the command line

sudo update-locale LANG=pt_BR.UTF8

in the end you run this

setxkbmap -model abnt2 -layout br -variant abnt2

and don't restart WSL yet, just try...

It worked like a charm. Thanks.

@laheinzen
Copy link

laheinzen commented Aug 20, 2022

Nothing of the above was working in a way that I liked in Win11. I wanted this to be automatic, and my choices (done in bashrc and wsl.conf) didn't work. This required running the command again. Also, sometimes it failed, even with the command.

Simplest workaround: changing the keyboard layout in Windows, from ABNT2 to ABNT. The Alt Gr key still works in Windows, and it is now working 100% on WSLg without any additional configuration.

@marcioandradejs
Copy link

setxkbmap -model abnt2 -layout br -variant abnt2

zsh: command not found: setxkbmap

SOLUTION
sudo apt-get update sudo apt-get install x11-xkb-utils

DONE! =D

https://command-not-found.com/setxkbmap

@Ri0n
Copy link

Ri0n commented Nov 21, 2022

I have a pretty similar problem.
My Windows layouts ru, en.
Tested with gvim with Ubuntu 22.04. I can switch from en to ru with a hotkey but not back. only setxkbmap -layout us switches back to us.
In terminal as usually all works well.

@kierke-gaard
Copy link

same here. I have German and US key-baord layout installed for Windows. When I switch to US layout and start wsl2, I have also us layout in the wsl2 bash. But emacs started from this bash has then German keyboard layout. really annoying, as emacs becomes useless with this keyboard layout :(

@nascimento210
Copy link

I don't know if matters, but I noticed that when I change the keyboard layout on windows the keyboard on linux gui app starts to work properly, maybe the solution is on what happen when we refresh the keyboard on windows.

@MouraVocal
Copy link

For my pt-br keyboard worked these steps:

1- in your zsh terminal type:

sudo dpkg-reconfigure locales

select PT-BR UTF-8 with space key on keyboard and click "ok"

2 - type a new command on terminal:

sudo apt update && sudo apt install x11-xkb-utils

3 - On your ~/.zshrc file adds the lines:

setxkbmap -model abnt2 -layout br -variant abnt2
WAYLAND_DISPLAY="wayland-1"

Don't forget to restart terminal for load zshrc file changes.

If you do not use Zsh, try to edit ~/.bashrc file instead

thanks @marcioandradejs and @PauloCotrim for the references

@dmajkic
Copy link

dmajkic commented Mar 16, 2023

When I switch keyboard layouts in windows, both "Serbian Latin" and "Serbian Cyrilc" keyboard layouts print cyrilic chars in WSL2 Wayland apps. Sloveninan, which I have also installed, is recognized OK and prints latin chars just fine.

$ setxkbmap -query
rules:      xorg
model:      pc104
layout:     rs
variant:    latinalternatequotes
options:    lv3:ralt_switch

@perrylets
Copy link

I have the same problem but I can't try the solutions proposed here because I use openSUSE Tumbleweed and some commands from the solutions are exclusive to ubuntu. ANyone know how to fix the issue on openSUSE? I'm using abnt, not abnt2.

@cassiocsantana
Copy link

Does anyone know how to persist, wsl.conf is not being executed, because I added 'command = ' and it didn't work

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

No branches or pull requests