Note: forked of this per recommendation here.

I made a foolish typo for UTF-8, and expected that when I fixed it, the keyboard on X would work right. Since making this errant change, I was no longer getting a Bash login, manpages, orlocale errors. But it didn't. Even if I do loadkeys pt-latin9, it never is able to fix the issue in X.

localectl gives:

[jmcf125@jmcf125-Toshiba-Arch ~]$ localectl
   System Locale: LANG=pt_PT.UFT-8
       VC Keymap: pt-latin9
      X11 Layout: pt

However, the real X keyboard layout is not pt, while it is so on the TTY. What's wrong here? Where can I set the layout right?

  • Although my answer solved this problem, I didn't mark it as an accepted answer because I'd like to see another solution, maybe without the .xinitrc. I promess that I'll mark it as an answer if it works.
    – JMCF125
    Jan 26 '14 at 18:09

At least in Arch, the keyboard settings are always separate for the console and the X, and in the case of the X, they are separated further by user (each with his/her/its $HOME/.xinitrc and related files).

So loadkeys only works for the console, the X has additional keyboard configuration layers. There are various ways to set the keyboard on the X.

To make the X keyboard settings permanent (or any other X start settings for that matter), put them on the .xinitrc file of your home folder. In this case, you only need the line:

setxkbmap -layout pt

(you may add & to make it load along other settings)

In your case, make sure the everything related to the layout is pt through setxkbmap -print -v 10 and that there is no pt(qwerty) nor pt-latin9 as those will not work even if they are the layout/keymap setting in your /etc/vconsole.conf file. This is what the line above takes care of.

  • I don't think this is a good idea to define your layout that late, unless you need a setup specific to that user. You should configure that in /etc/X11/xorg.conf.d/10-evdev.conf or using localectl set-x11-keymap. See slm's answer. I'm suspecting that if your keyboard is not properly setup at this stage, it's because there is a conflict in these files. (10-keyboard.conf and 10-evdev.conf maybe?)
    – Cilyan
    Feb 7 '14 at 21:37
  • @Cilyan, I've had this problem before. Interestingly enough, I don't have a /etc/X11/xorg.conf.d/10-keyboard.conf (only 00-keyboard.conf). I'll try to modify (and create) those to check the results. Thanks for the info.
    – JMCF125
    Feb 7 '14 at 23:50
  • Sorry, this is what I meant, 00-keyboard.conf. This is the one created by localectl. No need to create the files if they don't exist. Just check that your keyboard layout is not redefined in 00-keyboard.conf and 10-evdev.conf.
    – Cilyan
    Feb 7 '14 at 23:58
  • @Cilyan, indeed, inspecting /var/log/Xorg.0.log I have the line [ 196.050] (EE) Error loading keymap /tmp/server-0.xkm . So I probably have to get that right instead of overriding in .xinitrc...
    – JMCF125
    Feb 14 '14 at 13:25

I'm kind of naive when it comes to different layouts but can't you use localectl to set the layout to whatever you want to correct it?

$ localectl set-x11-keymap layout [model] [variant] [options]

You can use these commands to look up what the valid choices would be for the different X11 keymaps:

  • localectl list-x11-keymap-models
  • localectl list-x11-keymap-layouts
  • localectl list-x11-keymap-variants [layout]
  • localectl list-x11-keymap-options


  • Nope, localectl set-x11-keymap pt doesn't work, nor does localectl set-x11-keymap pt pc104 nativo, which AFAIK really should, as I have no special options. The problem is, as I identified above, pt(qwerty) (returned by setxkbmap -print -v 10) doesn't work for some reason. But I'd like to know why, so if you can find anything (again, web searches are not my strength), please do add it.
    – JMCF125
    Jan 26 '14 at 22:17

Note that, unless you tell it not to via "--no-convert", localectl will set the X settings to be equivalent to the console settings if you are setting console keymap via set-keymap and will set console equivalent to the X settings if you are setting the X keymap via set-x11-keymap. See man localectl.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.