Switching keyboard maps on openbox

In many common desktops there is a panel/taskbar combination that incorporates an available gadget/add-on “thingy” that you can click and switch between keyboard maps.  You may have customized maps or standard language mappings.  It will not change the painted characters on your keyboard but it will tell the system what character is on which combination of keys.  Openbox, out of the box, does not have such luxury.  You can use lxpanel, or lxqtpanel, or xfce4 panel, etc.  This kind of defeats the purpose of using openbox and trying to stay lean.  Otherwise if you have all the LXDE/LXQT GUI functionality in openbox you might as well run the whole other desktop based on openbox.

So this is a solution discovered recently by the developer of Miyo-Linux, who may have deviated slightly and produced an LXQT version, who loves to improve and enhance Openbox based on Devuan.  The solution works as far as we can tell on Openbox anywhere, so I employed it in Artix as well.

Try running this command first to see in what state is your X keyboard installation.

$ setxkbmap -print -verbose 10

In /etc/default/keyboard you can edit this keyboard definition and add a second or more languages (EDIT: 07112017:  Miyo corrected that the maximum of languages/keymaps you could have is four).  From a terminal you can enter a command such as

setxkbmap gb

which if you were in French would switch to UK-english.  In non latin based languages though then you are stuck in a terminal with unrecognizable commands, as this switch affects anythin X based (including terminal).:

or edit the above file and add:  us, fr, es switching with left alt + left shift

# KEYBOARD CONFIGURATION FILE
# Consult the keyboard(5) manual page.
XKBMODEL="pc105"
XKBLAYOUT="us,fr,es,gb"
XKBVARIANT=""
XKBOPTIONS="grp:lalt_lshift_toggle"
BACKSPACE="guess"

This is also done on the same keyboard file /etc/default/keyboard by adding a line such as:

XKBOPTIONS="grp:lalt_lshift_toggle"

If this does not work, there is also /etc/X11/xorg.conf.d/00-keyboard.conf

To be able to alternate between keyboard mappings/languages (example us,fr,es) with right alt + right shift the file should read as follows:

Section "InputClass"
 Identifier "system-keyboard"
 MatchIsKeyboard "on"
 Option "XkbLayout" "us,fr,es"
 Option "XkbModel" "pc105"
 Option "XkbOptions" "grp:ralt_rshift_toggle"
EndSection

This will have an effect only after reboot, or to be precise after X is shut down and restarted.  Please report back if you have any problems or in which cases this does not work so we can figure it out together.

PS – Edited:  The first method did not work on Artix but the second part with 00-keyboard.conf did.

3 thoughts on “Switching keyboard maps on openbox

  1. Miyo here. 🙂

    To my knowledge, one can only have four keyboard layouts (at one time). So keep that in mind when adding extra layouts. 😉

    Thank you for all that you do!

    Like

  2. Thank you anonymous,
    This is what I mean by open and collective knowledge being better than any single master ! 🙂

    Like

If your comment is considered off-topic a new topic will be created with your comment to continue a different discussion. This community is based on open and free communication, meaning we must all respect all in minimizing the exercise of freedom to disrupt such communication. Feel free to post what you think but keep in mind the subject matter discussed. It is just as easy to start a new topic as it is to dilute the content of an existing discussion.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.