How to set up XFCE4 XKB plugin to remember settings over reboots?
As the best previous answer appears to be commented afterwards by the user as not working anymore, I will give here an updated perfected version of a quite successful workaround. Sorry not to be able to provide a more scientific less empirical approach, I am not an advanced user, just had the luck to get what I want in this case and want to share this, maybe as a temporary patchwork. So, bare with me. I use Xubuntu, maybe some instructions are limited to that.
My solution is this (my case is English-US as default, second French, third Romanian standard - replace accordingly):
Go to Setting Manager > Keyboard > Layout, and set the languages in the preferred order (delete them and add them in order to achieve this). Go to the properties of the xkb plugin and make the same settings in the same order with the same default language.
Open the file
$HOME/.config/xfce4/xfconf/xfce-perchannel-xml/keyboard-layout.xml
Edit it to look similar to this.Open the file
$HOME/.config/xfce4/panel/xkb-plugin-##.rc
(replace ## with appropriate number). Edit it to look similar to this.Open the file
/etc/default/keyboard
(as root)
Edit it accordingly:
XKBMODEL="pc105"
XKBLAYOUT="us,fr,ro"
XKBVARIANT=",,std"
XKBOPTIONS="grp:alt_shift_toggle"
Maybe not all these are necessary to make it work, but just in case...
This is a known bug. I use xfce in arch linux and what I do is edit the ~/.config/xfce4/panel/xkb-plugin-##.rc
and add a new line or something and it works for some sessions. Another temporary fix may be what #31
suggests
1. Set the desired options in the plugin
2. Copy the ~/.config/xfce4/panel/xkb-plugin-##.rc to some other file e.g. ~/.config/xfce4/panel/goodxkb.rc
3. Add this command to a startup job:
sh -c "cp ~/.config/xfce4/panel/goodxkb.rc ~/.config/xfce4/panel/xkb-plugin-##.rc && pkill xkb"
(change the ## to your number)
The pkill part is crucial to reload the plugin and its config.
Just edit your /etc/default/keyboard
the way you want. The Xfce language indicator will then work correctly and the settings will not be forgotten.
- Go to Xfce Settings Manager => Keyboard => Layout. Here you have to make sure there is a tick next to "Use System Defaults". If you don't tick this, then you have to make sure that the languages selected here are exactly the same, and in exactly the same order as in
/etc/default/keyboard
and the Xfce language indicator. sudo nano /etc/default/keyboard
-
For example, if you want to be able to switch between English, Esperanto, German and Russian, make the following alterations (leave everything else as it is):
XKBLAYOUT="gb,epo,de,ru" XKBVARIANT=",,,phonetic" XKBOPTIONS="grp:alt_caps_toggle"
In the
XKBLAYOUT
section, make sure that you do not enter any spaces between the languages, otherwise the text will not be displayed correctly in language indicator in the Xfce panel.In the above example, the phonetic version of the Russian keyboard is being used, which is defined by the
XKBVARIANT
. The three commas are in front of the word "phonetic" as they tell the system that no variant is required for the three other preceding languages.XKBOPTIONS
defines the shortcut for switching between the languages. In this case, it is Alt + Caps Lock. Save the changes. In Nano, you do this by pressing Ctl + x, followed by y and then hit Enter.
Reboot your computer for the changes to take effect.
For information about what other variables can be placed in the file /etc/default/keyboard
, enter the following in the terminal: cat /usr/share/X11/xkb/rules/xorg.lst
. Here you can see the language codes, the types of variants, and also the shortcuts that can be used.
The Debian wiki also contains information about configuring the keyboard, and the XKB Configuration Guide is very useful too (it contains some excellent examples).