Sunday, October 14, 2012

Setup Keyboard Layout for OpenBox

OpenBox doesn't have a keyboard layout setup program to assist you, as ubuntu or window does. However it is not that difficult to do it yourself.  There are two things that you need to do: add new keyboard layout and show what current layout you are using. The easiest way to setup US and Thai keyboard layout for OpenBox is to add this two commands into you OpenBox autostart file, locale at: ~/.config/openbox/autostart

## enable thai keyboard 
setxkbmap -layout us,th -option grp:toggle
xxkb &
The command setxkbmap is setting layout to US(us) as the first layout and Thai (th) as second. I choose right-alt key to switch the layout by using option 'grp:toggle'. Learn more about other layouts or options, look at the file '/usr/share/X11/xkb/rules/base.lst'. You might want to read resources I listed at the end of the post too.

The second command xxkb will give you a layout switcher and indicator on your panel. Make sure you have the "&" at the end of the line, otherwise the autostart won't finished. The xxkb need a config file '.xxkbrc' in your home directory. Here is mine:

XXkb.mainwindow.enable: yes
XXkb.mainwindow.appicon: yes
XXkb.mainwindow.type: tray
XXkb.mainwindow.in_tray: yes
XXkb.mainwindow.geometry: 16x16+0+0
XXkb.mainwindow.label.enable: yes
XXkb.mainwindow.label.text.1: us
XXkb.mainwindow.label.text.2: th
XXkb.mainwindow.label.background: black
XXkb.mainwindow.label.foreground: white
XXkb.mainwindow.label.font: -misc-*-r-*-14-*

XXkb.controls.two_state: no
XXkb.group.alt: 2
XXkb.group.base: 1

XXkb.button.enable: no
XXkb.bell.enable: no
Certainly, I do not know all the options for the .xxkbrc, but at least I need to match the *.label.text.1 to us, and *.label.text.2 to th. It's the order of layout that I set in setxkbmap. If you prefer graphic, instead of text, read [1]. Surely, you can play around with foreground, background, and font.

This setup will give you a user level setup. It's won't stay around when you logout of your acccount. To do system-wise setup, you need to twist your X-window configuration files, and I won't get into that in this post.

Here some resources that I fine helpful. Thanks for reading :)

[1] http://crunchbanglinux.org/forums/topic/12727/keyboard-layout-switcher-and-indicator-for-usqwertyusdvorak/
[2] http://forums.freebsd.org/showthread.php?s=a893694385754994b12f193e01a5af91&t=10500
[3] http://forums.freebsd.org/showthread.php?t=25506
[4] http://betabug.ch/blogs/ch-athens/1242

No comments:

Post a Comment