Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: Cannot configure keyboard layout with multiple languages. (Read 3609 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Cannot configure keyboard layout with multiple languages.

Dear Artix community,

a couple of months ago I installed Artix and I am very pleased with it.

I have installed it on a Lenovo Thinkpad X220, german qwertz keyboard with the following set up:

artix base install + Runnit + DWM + ST as my main Terminal
along with URXVT. I need the latter for different work.

I am switching over to Artix from Ubuntu, Xubuntu to be precise, and I have never used it before.
Nor did I ever use Arch either.

Everything works well. It is very stable and very fast.
There are a some minor configuration issues that I want to try to solve by myself. Issues that are not
paramount. But there is one big issue that is:

I cannot configure my Keyboard to use the italian layout as primary layout and german as secondary layout
and the English GB or US Layout as third one.

In order to improve my English I set up the system language to English during the install so all text output on the
terminal is in this language. And that is perfect.
However I have been trying for the past week to change the keyboard
and I have read the Artix, Arch and even the Gentoo wiki on how to do it. The last thing I did was configuring an Xorg file for it,
but it still does not work. toggling between languages just worked. But it could not determine either of the
special letters in neither Italian nor German. The only configuration that did work was setting the vconsole to Italian.
That was very simple and straight to the point. Since I cannot change the layout in the "normal System",
I am stuck. I cannot write documents, nor can I answer emails.
Therefore I am forced to use my xubuntu linux install. Now, I will provide further information on what I have
tried so far.


This is what I did after the installation process. I try to remember the chronological order:

01. following the artix install guide I have changed the Vconsole language editing /etc/conf.d/keymaps adding
       loadkeys=it, saved it and it worked.

02. Then I have set the locale, uncommenting the locale in /etc/locale.gen, selecting en_GB.UTF-8

03. Run the command locale-gen

        Output: Generating locales...
           en_GB.UTF-8... done
           Generation complete.

04. I uncommented de_DE@euro ISO-8859-15 and the same for Italian. Then I ran locale-gen once
        more and got the same output mentioned on point 3.

05. The keyboard did not detect the Italian nor German  layout, though. Therefore, I ran the "locale" command,
        to check if everything was set up correctly. The output is this:

   LANG=C
   LC_CTYPE="C"
   LC_NUMERIC="C"
   LC_TIME="C"
   LC_COLLATE="C"
   LC_MONETARY="C"
   LC_MESSAGES="C"
   LC_PAPER="C"
   LC_NAME="C"
   LC_ADDRESS="C"
   LC_TELEPHONE="C"
   LC_MEASUREMENT="C"
   LC_IDENTIFICATION="C"
   LC_ALL=

06. I switched over to my xubuntu laptop and repeated the "locale" command again. Since my xubuntu keyboard
        layout is set up correctly I wanted to compare both outputs
        In Xubuntu I got:

   LANG=en_US.UTF-8
   LANGUAGE=en_US
   LC_CTYPE="en_US.UTF-8"
   LC_NUMERIC=it_IT.UTF-8
   LC_TIME=it_IT.UTF-8
   LC_COLLATE="en_US.UTF-8"
   LC_MONETARY=it_IT.UTF-8
   LC_MESSAGES="en_US.UTF-8"
   LC_PAPER=it_IT.UTF-8
   LC_NAME=it_IT.UTF-8
   LC_ADDRESS=it_IT.UTF-8
   LC_TELEPHONE=it_IT.UTF-8
   LC_MEASUREMENT=it_IT.UTF-8
   LC_IDENTIFICATION=it_IT.UTF-8
   LC_ALL=

   As one can see, I did something wrong.

07. "Reuncommented" Italian and German in /etc/locale.gen to avoid complicating the issue.
         Ran locale-gen again, one time accidentally with "sudo". It generated completely as expected.

08. Ran the "locale" command again. At this point I had only British English set up as before.
       But nevertheless I got the same output once more:

   LANG=C
   LC_CTYPE="C"
   LC_NUMERIC="C"
   LC_TIME="C"
   LC_COLLATE="C"
   LC_MONETARY="C"
   LC_MESSAGES="C"
   LC_PAPER="C"
   LC_NAME="C"
   LC_ADDRESS="C"
   LC_TELEPHONE="C"
   LC_MEASUREMENT="C"
   LC_IDENTIFICATION="C"
   LC_ALL=


09. I went back to the Artix installation page under "Configure the base system -> localisation" and
       created the file /etc/locale.conf and wrote something in it, but I do not recall it, since I have
       deleted it the day after, because it did not solve the issue. I was not sure at this point,
       if locale.conf was the file I needed. So local.conf is empty. Neither did I source nor export its content
       before deletion to my bash.rc as described in that section. The reason why I did not do it is because
       I did not (and still do not) understand the variables of the command "locales". Specifically which variable
       sets the keyboard layout of a given country. (Even though I have read the Gentoo wiki article which explains these variables).

10. Went to the Artix page. This time under "Configuration --> Runnit -->
       Keyboard configuration in console" and clicked on the link "Arch manual..." which opens "vconsole.conf.5", read that
       but it did not solve the issue. -until I understood that it does not affect the keyboard settings in
       normal user mode - .

11. Read the man page for xorg.conf where it explains that the keyboard needs to be configured under
      "input devices"

12. With that in mind I went to the Arch Linux wiki on the following link:

       https://wiki.archlinux.org/index.php/Xorg/Keyboard_configuration

       in the section "using xorg configuration files" there is an example on how to set up the keyboard:

       /etc/X11/xorg.conf.d/00-keyboard.conf

        Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "cz,us"
        Option "XkbModel" "pc104"
        Option "XkbVariant" ",dvorak"
        Option "XkbOptions" "grp:alt_shift_toggle"
EndSection

So I created the 00-keyboard.conf since it did not exist, with the following specifications:

Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "us,it,de"
        Option "XkbModel"  "thinkpad"
        Option "XkbVariant" "qwerty"
        Option "XkbOptions" "grp:shifts_toggle"
EndSection

After that it does finally change the layouts, however every time I press Italian letters such as "a, o, u, e"
that have accents on them, the system does not recognise them. Instead as output I get a question mark in
ASCII (I believe it's ASCII, not sure). The same happens in German when I want to type a letter with "Umlaut"
or the German "scharfes S" (I don't know how it's called in English). It does not work.



13. I went on the Artix Linux Forum on this thread:

       https://forum.artixlinux.org/index.php/topic,954.0.html

       There is an similar entry

    Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "us,br"  ##  <<<------   edit this to the right one
        Option "XkbModel" "pc105"
        Option "XkbOptions" "grp:alt_shift_toggle"
EndSection

 After trying that out by replacing the  Option XkbModel with "pc105"  it did not work either. So I switched back to my layout above on point 12.


At this point, the only source I did not consult, is the Arch Linux Forum.

I apologise, if this thread has gotten to long. If so, feel free to delete it.

May anybody help, please? Thank you very much for your time.

EDIT: before posting this I have noticed that in my config file:

Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "us,it,de"
        Option "XkbModel"  "thinkpad"
        Option "XkbVariant" "qwerty"
        Option "XkbOptions" "grp:shifts_toggle"
EndSection

under "xkbVariant" I wrote qwerty and not "qwertz", so I changed it, since my laptop has a German keyboard. However, even this does not work. Therefore I put it back to "qwerty".

(SIDE NOTE: while checking this thread before posting It, I have discovered that typing on this forum the special letters  do work, look:

Italian: ò à è é ù ,
German: ä  ö  ü ß

Apparently it does not work in either of my terminals  st or urxvt.

What am I missing?

Re: Cannot configure keyboard layout with multiple languages.

Reply #1
(SIDE NOTE: while checking this thread before posting It, I have discovered that typing on this forum the special letters  do work, look:

Italian: ò à è é ù ,
German: ä  ö  ü ß

Apparently it does not work in either of my terminals  st or urxvt.

That is strange... maybe your terminal itself can not display them? I would, as a test, try a new terminal. I do not use urxvt (go suckless!) but if I remember it's default font dose not support the characters as all. I would try changing the font of the terminal to one you know supports those characters. I think the nest step is to just try some other terminals and see if that fixes, but I suspect that if you can type into webpages and documents using the non english characters, then the actual localization may be working. Firefox for instance uses its own internal fonts and also fonts are taken from the webpage unless you have blocked it.

Yeah, anyway. I think checking the font the terminal uses, and then if no luck trying a different terminal maybe the way to go before screwing around with the system files more.
https://wiki.archlinux.org/index.php/List_of_applications#Terminal_emulators (ST, Kitty, Alacrity is good but heavy)

Re: Cannot configure keyboard layout with multiple languages.

Reply #2
If you run
Code: [Select]
$ locale -a
you should see the locales you have. To get more you need to edit /etc/locale.gen and uncomment the ones you want. Then run:
Code: [Select]
# locale-gen
(I usually use sudo - not aware it matters)
Your default locale can be exported in /etc/profile.d/mylocale.sh which should be executable, and there are other possible locations to do this:
Code: [Select]
#!/bin/sh
export LANG="xx_XX.UTF-8"
Then you can run things using another of the locales you have created like this:
Code: [Select]
$ LANG=de_DE.utf8 ls --version
ls (GNU coreutils) 8.32
Copyright © 2020 Free Software Foundation, Inc.
Lizenz GPLv3+: GNU GPL Version 3 oder höher <https://gnu.org/licenses/gpl.html>.
Dies ist freie Software: Sie können sie ändern und weitergeben.
Es gibt keinerlei Garantien, soweit wie es das Gesetz erlaubt.
Geschrieben von Richard M. Stallman und David MacKenzie.

As for keymaps I'm not sure. I think the keymap is loaded by loadkeys in /etc/init.d/keymaps, but that might be the console keymap and the desktop could have it's own system and load another keymap later in the boot for use in X.
I was trying some stuff with xev, showkey and xmodmap, and was able to add a £ sign to a US KB on SHIFT INSERT  like this:
Code: [Select]
$ xmodmap -pke | ag 'insert'
keycode  90 = KP_Insert KP_0 KP_Insert KP_0
keycode 118 = Insert NoSymbol Insert
$  sudo xmodmap -e 'keycode 118 = Insert sterling Insert'
and running that xmodmap without the sudo as a startup command in XFCE it works automatically. When I tried it on the Windows/Super key it didn't work in the browser but did elsewhere, some apps may impose their own special mappings. So that's one way to at least modify a keymap if not change it outright  ;D I would try to add and set the extra keymaps in the XFCE settings menu keyboard layout GUI (or equivalent in another desktop) if possible.
You'd also need the fonts for the characters, although probably you would have them already.
(I have Terminator because it does some split screen things although it starts slower than XFCE4 terminal, which has a save contents right click menu option Terminator lacks.)

Re: Cannot configure keyboard layout with multiple languages.

Reply #3
Hello everyone,

first of all thank you for your answer. Sorry for my late reply.

Here are the steps I have taken after your suggestions:

1. First Installed urxvt in xubuntu to check whether the keyboard layouts would work. And, indeed,
    they do. Italian and German letters work out of the box. I do not know why it does not work in Artix.

2. Then as Question Bot suggested I installed Terminator and the Kitty terminal in Artix to see
     if the layouts work. And they do. In both terminals.

3. Changed the fonts in st and urxvt. However, it did not work.

4. Read this article, but I did not quite understand it a 100%. At least for me, it is difficult,
     but I will read it again:

     https://wiki.archlinux.org/index.php/Environment_variables

5. I ran the command "locale -a" to see all the current locales.
   The output:
                C    
                POSSIX
                en_GB.utf8

6. edited /etc/locale.gen to uncomment German and Italian

   de_DE.UTF-8 UTF-8
   it_IT.UTF-8 UTF-8


7. Ran locale "locale-gen" again. Now the current output is:

                C <----------------- This must be the default variable in /etc/profile.d/locale.sh, right?
                POSIX
                de_DE.utf8
                en_GB.utf8
                it_IT.utf8

(I also added Spanish later)


8. Went into my /etc/profile.d/locale.sh and added at the bottom:

   #!/bin/sh
   export LANG="en_GB.UTF-8" <----- since I want all the terminal text output to be in English

Now my locale.sh looks like this:

#!/bin/sh

# load locale.conf in XDG paths.
# /etc/locale.conf loads and overrides by kernel command line is done by systemd
# But we override it here, see FS#56688
if [ -z "$LANG" ]; then
  if [ -n "$XDG_CONFIG_HOME" ] && [ -r "$XDG_CONFIG_HOME/locale.conf" ]; then
    . "$XDG_CONFIG_HOME/locale.conf"
  elif [ -n "$HOME" ] && [ -r "$HOME/.config/locale.conf" ]; then
    . "$HOME/.config/locale.conf"
  elif [ -r /etc/locale.conf ]; then
    . /etc/locale.conf
  fi
fi


# define default LANG to C if not already defined
LANG=${LANG:-C}

# export all locale (7) variables when they exist
export LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \
       LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT \
       LC_IDENTIFICATION


# systemlanguage <-------- This is the part that I have added.

#!/bin/sh
export LANG="en_GB.UTF-8"


I have one quick question regarding the "# export all locale (7)  variables when they exist" part
If I want to add variables I simply have to put them under my "export LANG="en_GB.UTF-8"
section for example:

#!/bin/sh
export LANG="en_GB.UTF-8"
       LANGUAGE="xx_XX.UTF-8"
       LC_CTYPE="xx_XX.UTF-8"
       LC_NUMERIC="xx_XX.UTF-8"

       ecetera, ecetra. Is that correct?

Question 2: In the Arch Wiki it is written that normally you should put this configuration in /etc/locale.conf
I have mine in /etc/profile.d/locale.sh. On my system /etc/locale.conf is
empty. Which one is better? I am asking because I want to use the most efficient way possible.


9. Then I executed this command exporting my language of choice and repeated the process for each
   additional language:

   LANG=xx.XX.utf8 ls --version

For instance: LANG=de_DE.utf8 ls --version


Finally, it worked!

Now, to conclude this post , I would like to summarize the important steps I have taken and
I would like to ask you, if you could please confirm it with your comments, so I can be sure I that
I did understand this procedure or if I did something wrong. If I did it right, I will mark this post as "solved".
 It is also intended for people who might
have the same issue that I had. Furthermore, If I understood it,
I can install Artix on other machines and set up my keyboard layouts without issues.




-----------------------------------------------------------------------------------------------------

Intended for Artix base install:

Setting the system language to English while setting/using keyboard layouts in different languages:


01. Check what your current enabled locales are. Run:

       "locale -a"

02. Edit the file /etc/locale.gen.  Uncomment the languages you need. In this case:

       de_DE.utf8
       en_GB.utf8
       es_ES.utf8
       it_IT.utf8


03. Then run: locale-gen. If all went well the output will be:
 
       "Generation Complete".


04. In /etc/profile.d/locale.sh add:

       #!/bin/sh
       export LANG="xx_XX.UTF-8" <----- language of choice in which the system displays text.
                                                                               for example: man pages in the terminal.


05. Export "activate" the additional languages for your different keyboard layouts.
       Run this command for each language:

       LANG=xx_XX.utf8 ls --version

06. In order to switch between your keyboard layouts go to
       /etc/X11/xorg.conf.d/ and create an 00-keyboard.conf file with this structure:


         Info: your entries in: XkbLayout, XkbModel, XkbVariant and XkbOptions, might differ from mine.
         Choose the appropriate ones.

   Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "gb,it,de,es"
        Option "XkbModel"  "thinkpad"
        Option "XkbVariant" "qwerty"
        Option "XkbOptions" "grp:shifts_toggle"
   EndSection



 Info:

 Once your log into your system, the System will search in XkbLayout and will choose the
 keyboard layout that is on the left.
 Left is default. In this case: first gb English. second Italian and so on. So if you
 log in into your System and you want the keyboard layout to be in a different language, put the
 language of your choice on the left.

 In XkbOptions you can set the key combination to be pressed in order to switch between your
 different layouts. The key combinations can be found in: /usr/share/X11/xkb/rules/base.lst.
 They start with grp: and end with toggle.

 All the other Xkb entries can also be found in that file.


07. Reboot the system.

Thank you everyone for your help  8)

P.S. please, let me know what your thoughts are. Thank you!

Re: Cannot configure keyboard layout with multiple languages.

Reply #4

P.S. If I could I would go suckless immediately. The problem is that I have tried to patch st, for instance with "scrollback", but it gives me an error. I have also followed tutorials on youtube, but I cannot figure it out (yet). The same goes for DWM.
I do not know in which file I have to add and substract lines, since it differs form patch to patch as far as I can tell.  :)

 

Re: Cannot configure keyboard layout with multiple languages.

Reply #5

As for keymaps I'm not sure. I think the keymap is loaded by loadkeys in /etc/init.d/keymaps, but that might be the console keymap and the desktop could have it's own system and load another keymap later in the boot for use in X.

Yes, Indeed! The loadkeys command only changes the keyboard layout of the vconsole (tty).

That was the first thing I did and it was easy compared to X. :)