Openbox and keyboard layout

How to define an additional keyboard layout? Simple - you go to keyboard settings and add it. Then you define a keyboard shortcut and add a panel widget. Done.
Alas, it's not always so simple. Like this or this. It might be that your 'locales'-change simply doesn't impress your desktop, OR that you are plain arrogant and using boxen (as opposed to well-established DE which have this nice-and easy 'keyboard settings' place).

So I was in Debian Sid and using Openbox ... I wanted to add Thai or Greece or Estonian or Ethiopian or Russian layout-option. By the way, while Greece is 'gr' and Russian is 'ru', it's Ethiopian that is 'et' and Estonian is 'ee'... and there are other abreviations which do not go by countries ISO-standard.
What I did (after reading ungodly amounts of google-trash):
... Edited those two files:
# /etc/default/keyboard 
# (this adds classic Windows' alt+shift switch,
## And also in file /etc/X11/xorg.conf 
Section "InputDevice"
Identifier "Generic Keyboard"
Driver "kbd"
Option "XkbRules" "xorg"
Option "XkbModel" "pc105"
Option "XkbLayout" "us,th,gr,et,ee,ru"
Option "XkbOptions" "grp:alt_shift_toggle" 
To work, those locales have to be installed, of course. Testing - open editor, type, switch keyboards, type...
If you want to have clickable switcher on panel, install systray app: fbxkb app didn't work for me (bug with US flag)... but I had no problems with xxkb app.
xxkb needs also config file in your home - .xxkbrc (and logout-login after creating it). Following worked for me:
XXkb.mainwindow.enable: yes
XXkb.mainwindow.appicon: no
XXkb.mainwindow.type: tray
XXkb.mainwindow.in_tray: yes
XXkb.mainwindow.geometry: 16x16+0+0
XXkb.mainwindow.border.color: white
XXkb.mainwindow.border.width: 1 
XXkb.mainwindow.label.enable: yes
XXkb.mainwindow.label.text.1: US
XXkb.mainwindow.label.text.2: FR
XXkb.mainwindow.label.foreground: white
XXkb.mainwindow.label.font: -misc-*-r-*-13-*
XXkb.controls.two_state: no 1 2
XXkb.button.enable: no
XXkb.bell.enable: no 
And it's, of course, convinient to have xxkb in autostart (I put it as the last entry):
(sleep 3s && xxkb) & 

Bug: Every similar shortcut will be fucked by xorg when you are using locale-shortcut. Means, anything longer (than, in this case, alt+shift) that uses the same combination, does not work. The bug has been up 5 years at least ...

Not wanting a hassle of file-hacking and setting up a switcher? You can type in terminal:
setxkbmap -rules xorg -model pc105 -layout "us,gr,ru" -option "grp:alt_shift_toggle"
You will have shortcut-switch for this session - and it works too.
If above-written didn't work OR you want to go deep: Google. There are piles of reading about this. Quaranteed to drive you at least slightly crazy.

No comments: