Using multiple keyboard layouts

Original forum link
https://forum.qubes-os.org/t/19029
Original poster
taradiddles
Editors
deeplow
Created at
2023-06-02 06:34:28
Last wiki edit
2023-08-14 20:30:28
Revisions
2 revisions
Posts count
2
Likes count
3
Tags
configuration, version-r40

The official Qubes OS faq entry only covers how to change the layout globally - ie. both for dom0 and VMs, with a single layout.

This document shows several ways of using multiple keyboard layouts and being able to quickly switch between them.

Recommended setup

Run setxkbmap in each VM. Dom0 stays untouched (running setxkbmap in dom0 too will interfere with the VM's setxkbmap setup).

For instance the following command would alternate between the US English and the Bulgarian phonetic layout when pressing both shift keys:

setxkbmap -layout "us,bg(phonetic)" -option "grp:shifts_toggle"

To automatically run the setxkbmap command when the VM starts, add a /etc/xdg/autostart/setxkbmap.desktop file in the VM's template with the following content:

[Desktop Entry]
Name=Configure multiple keyboard layouts
Exec=setxkbmap -layout "us,bg(phonetic)" -option "grp:shifts_toggle"
Terminal=true
Type=Application

Note: for some reason, with Terminal=false the setxkbmap settings aren't applied until one runs setxkbmap without options in a terminal. Setting Terminal=true works around this problem, but you will notice a terminal flicker at startup.

If you prefer to have a per-vm setup rather than per-template, create a /rw/config/setxkbmap.desktop with the same content as above and add the following line to /rw/config/rc.local:

cp /rw/config/setxkbmap.desktop /etc/xdg/autostart

Note: the reason we can't put the setxkbmap command in the rc.local script is because the X server isn't running when rc.local is executed.

Alternatively, you could add the setxkbmap command to your profile's .bashrc file if you use terminals to start applications.

Alternative setups


This document was migrated from the qubes-community project