Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: [SOLVED] Switching between multible keyboard layouts (Read 1794 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[SOLVED] Switching between multible keyboard layouts

Dear all,

I recently set up a base install of Artix Linux with a minimalistic set of programs and dwm as its window manager. I am using an italian keyboard but would like to being able to switch to the us layout with a key binding. I followed the instructions in this topic. Namely:

1) uncommenting the desired locales in /etc/locale.gen (in my case, it_IT.UTF-8 and en_US.UTF-8),

2) run sudo locale-gen to generate the desired locales (with the expected output), and

3) created a 00-keyboard.conf file in /etc/X11/xorg.conf.d with:

Code: [Select]
Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "it,us"
        Option "XkbModel" "thinkpad"
        Option "XkbVariant" "qwerty"
        Option "XkbOptions" "grp:alt_shift_toggle"
EndSection

However, after a reboot, pressing alt+shift doesn't switch between the two layouts. In my .xinitrc file I have this line:

Code: [Select]
setxkbmap it &

because I want the default layout to be italian. However maybe this is the issue, or i didn't install some packages. Do any of you have some suggestions?


Re: Switching between multible keyboard layouts

Reply #2
Thank you @strajder. So basically all the previous steps I did are useless in dwm? May I delete the 00-keyboard.conf file?

Re: Switching between multible keyboard layouts

Reply #3
That topic is related to setting XKB on Thinkpad. You can also set it up using a .conf file, but it needs to match your keyboard model. See the official documentation.

In my dwm setup, I'm not using any special X.Org configuration files, which fits the theme of my "portable" fork of dwm. For example, when I install different guests in QEMU, I just pick up my fork of dwm to have a lot of the settings, like my dwm keyboard shortcuts, starting st + tmux window, etc, and XKB layouts, working "out of the box".

Edit: Just tested in a XFCE OpenRC guest, this should work after X.Org restart or reboot if using DM:
Code: [Select]
# Read and parsed by systemd-localed. It's probably wise not to edit this file
# manually too freely.
Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "us,rs"
        Option "XkbOptions" "grp:alt_shift_toggle"
EndSection
 
If not, check your X.Org log.

Re: Switching between multible keyboard layouts

Reply #4
1. Use

Code: [Select]
$setxkbmap -print -verbose 10

to find out your keyboard model and configure  /etc/X11/xorg.conf.d /00-keyboard.conf accordingly

2. Remove this line in your .xinitrc

Code: [Select]
setxkbmap it &

X picks the first value in XkbLayout as default.

3. You may have missed step 04 and 05 in his summary section.

 

Re: Switching between multible keyboard layouts

Reply #5
Quote
2. Remove this line in your .xinitrc

Code: [Select]
setxkbmap it &

X picks the first value in XkbLayout as default.

@calvinh yes, that was it! Thanks a lot! I marked this as "solved".