Endless Keyboard Layout Problems / Tried countless solutions

Greetings people,

I use Zorin OS 16 with X11 windowing system and my Gnome Shell version is 3.38.4, and everything is properly updated.

The background to my problem is the following: I was trying to solve a crash that was presented when I changed my screen brightness, when a guide ended up leading me to two possible solutions: the first involved uninstalling some Nvidia drivers, and the second, change my system language. After uninstalling the Nvidia drivers, I made the grotesque mistake of not checking to see if the problem was resolved before moving on to the second solution (change the language), so I don’t know what exactly generated my current problem, which is:

Some keys on my keyboard (I’ll focus here on the bracket keys to make it easier to understand) are switched. In short, my keyboard doesn’t work like it used to and it`s impossible to type properly.

I looked for numerous solutions focused on Ubuntu, because I didn’t find many specific resolutions for Zorin (although I think this isnt a problem `cause I was able to reproduce the solutions quite well), but I’ll try to list them here to facilitate a possible help, because this has caused me a lot of stress already:

  • I use and have always used my system in English, but my keyboard is brazilian portuguese.

  • In Settings > Region & Language > Input Sources, I am informed that my keyboard is in Portuguese (Brazil), however when I click to view the layout of that language, the displayed keys do not correspond to my pressed physical keys; for example, the left and right bracket keys appear next to each other in all possible layouts, but in my notebook they are on top of each other, next to Enter.

(https://i.stack.imgur.com/96LLF.jpg)
My keyboard.


Default Layout showed on my computer (Portuguese Brazil)

  • I have another notebook with the same version of Zorin, the same version of Gnome Shell, also from Acer, and with the identical keyboard, AND ITS ALSO configured in Input Sources as Portuguese (Brazil), BUT its layout corresponds perfectly to it`s physical keyboard.

In view of this information, I tried several solutions, including:

  • I did a clean boot (with Recovery Mode) in various ways (repairing broken packages etc) and even uninstalled all Nvidia drivers to make sure they weren’t interfering with my keyboard recognition, which is the case with some people I’ve seen.

  • Currently my graphics are in Noveau, as Nvidia graphics are completely uninstalled and disabled. Therefore, I disregarded the influence of Nvidia drivers.

  • I tried to use all the other variants of the keyboard in Portuguese (even English International, dead keys etc etc), selecting them in that same default interface of the keyboard settings and they all display the wrong layout, and every time my computer was restarted when necessary to apply changes; always unsuccessfully.

  • I tried this code in terminal,

    setxkbmap -model abnt2 -layout br -variant abnt2

and variants of it, which I found on the internet, hoping to force the system to recognize my keyboard as ABNT2, but the following error is displayed in the terminal after pressing enter:

Error loading new keyboard description

  • I tried everything to fix this error, without success.

  • Also, one of the first solutions I tried was to change files in folders related to keyboard functioning on startup (/etc/default/keyboard, for example); I don’t remember any other files that I tried to change but was always unsuccessful.

  • I also tried to reconfigure the keyboard by dpkg via terminal:

    sudo dpkg-reconfigure keyboard-configuration

The command worked normally and I can follow the wizard’s instructions, but regardless of my selections, the application does not have any immediate effect, nor after restart, and there is no indication that there is a problem saving this reconfiguration.

I may have done something wrong, but I’m trying to isolate the problem cause I’ve tried everything I could. All this text was written on another computer and passed here, otherwise it would be impossible to read the topic. I ask for your help and I hope it will be useful to more people if solved. I`ll make myself available to respond. Thanks in advance!

Hello @clauscanddie

I sympathize with your frustration; you’ve clearly done your homework and tried a myriad of solutions. Let’s see if we can narrow this down further and get your keyboard behaving properly again.

Given that your issue occurred after two primary actions (uninstalling Nvidia drivers and changing the system language), and since you’ve already eliminated Nvidia drivers as a potential cause, it’s possible that the language settings change has had unintended consequences.

Here are a few steps to try and get your keyboard functioning normally:

  1. Reset All GNOME Settings:
    It’s possible some GNOME settings related to keyboard mapping got corrupted. Try resetting all GNOME settings to defaults:

    dconf reset -f /
    

    After this, restart your machine.

  2. Directly Check the Keyboard Configuration File:
    Inspect the contents of /etc/default/keyboard. It should contain something similar to:

    XKBLAYOUT="br"
    XKBMODEL="abnt2"
    

    Ensure the settings match your desired configuration. If not, edit the file:

    sudo nano /etc/default/keyboard
    

    Change the necessary settings, save, and exit (CTRL+X, then Y, then Enter). After making changes, restart your system.

  3. Alternative Keyboard Configuration Tools:
    Instead of GNOME’s built-in tools, use xinput and setxkbmap directly.

    • List the input devices:

      xinput list
      

      Identify the id number of your keyboard.

    • Fetch the current keyboard settings:

      setxkbmap -query
      

      This will let you see the current keyboard layout settings.

    • Force-set the keyboard layout:

      setxkbmap -layout br
      

      This will set the keyboard layout to Brazilian Portuguese.

  4. Profile Check:
    Create a new user profile on your Zorin OS and see if the problem persists on the new profile. This will help ascertain if the problem is systemic or specific to your user profile.

  5. Reinstall Input Method Framework:
    Sometimes, reinstalling the Input Method Framework can help:

    sudo apt-get install --reinstall ibus
    

    Once done, restart your system and see if the issue is resolved.

  6. System Upgrade:
    Even though you mentioned that everything is properly updated, just to ensure you didn’t miss any critical updates or patches, run:

    sudo apt update
    sudo apt upgrade
    sudo apt dist-upgrade
    

    Then, restart your system.

If none of these solutions work, you might be dealing with a deeper system issue or possibly a bug specific to the Zorin OS distribution that you’re using. If that’s the case, I recommend visiting the official Zorin OS forums or support communities and detailing your issue there.

Lastly, always keep backups before making significant system changes, so you can revert if needed. I sincerely hope one of the steps above resolves your issue!