Openbox: Switch languages using the keyboard and xxkb

From Manjaro Linux
Jump to: navigation, search



Overview

The installation of the Openbox variant of Manjaro Linux does not provide an "Out Of The Box" Command Line or Graphical Tool for changing between multiple installed languages (Unlike some other heavyweight DEs. See GNOME, KDE, etc). One way of overcoming this pitfall is to manually edit some key System-Files and use a Third-Party Graphical Language-Keyboard Switcher.

This guide shows you how to achieve Language-Keyboard Switching using System-Files Editing and the Third-Party Tool XXKB.[1] The configuration shown here is the minimum possible in order to achieve the goal (More extensive configuration can be used).

This guide assumes the following:

  1. The Name of the user configuring the system is "Jimmy".
  2. The Languages that need to be switched are English (United Kingdom) and Greek (Polytonic).
  3. English (United Kingdom) is the default system language.
  4. The Key-Combination that will be used for the switching is Left Alt + Left Shift.


Install the prefered languages

Edit file /etc/locale.gen

sudo nano /etc/locale.gen

Uncomment only the lines for the required languages. In this case the lines

el_GR.UTF-8 UTF-8
en_GB.UTF-8 UTF-8

and save.


Regenerate locales for the changes to take effect

sudo locale-gen


Enable Console language switching

Edit file /etc/vconsole.conf

sudo nano /etc/vconsole.conf

Change the content to read

KEYMAP=uk
KEYMAP_TOGGLE=gr

and save.


Enable X11 language switching

Edit file /etc/X11/xorg.conf.d/20-keyboard.conf

sudo nano /etc/X11/xorg.conf.d/20-keyboard.conf

In section "InputClass", after the line Identifier "system-keyboard", add the lines

Option "XkbLayout" "gb,gr(polytonic)"
Option "XkbOptions" "grp:lalt_lshift_toggle,terminate:ctrl_alt_bksp"

and save.

!!! If you have used the MHWD utility to configure your graphics card, then there will be a file 90-mhwd.conf. For the changes you have made in file 20-keyboard.conf to work, you have to edit this file and comment out the line with the XkbOptions, in section InputClass, as below:

Section "InputClass"
	Identifier          "Keyboard Defaults"
	MatchIsKeyboard	    "yes"
	#Option              "XkbOptions" "terminate:ctrl_alt_bksp"
EndSection


Install & configure graphical language switcher (xxkb)

Install program xxkb

sudo pacman -S xxkb


Create folder in /home/jimmy/.config that will hold the language flag images used by the xxkb switcher

sudo mkdir /home/jimmy/.config/xxkb


Go to any site providing free images of country flags and download the flag images for United Kingdom and Greece.


Resize the flag images you downloaded to 20x20 pixels and convert them to be of type xpm.


Rename the flag images to gb.xpm and gr.xpm for United Kingdom and Greece respectively.


Copy the flag images into the folder /home/jimmy/.config/xxkb that you have previously created.


Create configuration file for xxkb in user's home folder.

sudo nano /home/jimmy/.xxkbrc

Edit it to read

XXkb.image.path: /home/jimmy/.config/xxkb

XXkb.group.base: 1
XXkb.group.alt: 2


XXkb.mainwindow.type: tray
XXkb.mainwindow.enable: yes
XXkb.mainwindow.appicon: yes
XXkb.mainwindow.border.width: 1
XXkb.mainwindow.label.enable: no
XXkb.mainwindow.border.color: white
XXkb.mainwindow.geometry: 20x20+0+0
XXkb.mainwindow.image.1: gb.xpm
XXkb.mainwindow.image.2: gr.xpm
XXkb.mainwindow.image.3: 
XXkb.mainwindow.image.4: 
XXkb.mainwindow._delete: no

XXkb.button.enable: no

XXkb.controls.focusout: no
XXkb.controls.two_state: no
XXkb.controls.add_when_start: yes
XXkb.controls.add_when_create: yes
XXkb.controls.add_when_change: no

and save.


Make xxkb autostart when openbox starts

Edit openbox's autostart configuration file

sudo nano /home/jimmy/.config/openbox/autostart

In section ##Startup, after the last line, add the line

(sleep 1s && xxkb) &

and save.


Reboot the operating system

sudo reboot