Recent Post

Friday, November 29, 2013

Create Input Method Table for SCIM - Linux

Commonly people form country which has its own alphabet and writing system, usually has a standard keyboard layout to type or write something with their writing system especially for not latin alphabet, with this we can write documents, articles, make logo and anything which comply such writing system, actually there is still another way to fulfill our needed without changing our keyboard layout, but we can still typing any inscription we desire just like typing with common keyboard layout (common English keyboard layout)
 
SCIM (Smart Common Input Method) token form wikipedia.org it's “an input method (IM) platform containing support for more than thirty languages”.

There are lots of IMEs that have been developed for all of the most commonly used language in the world and are well supported in Linux, there are similar programs such IBus and UIM. Thought there are many input methods available, but sometimes we may need something special which we will not find IMEs for these language (at least now) or we want to input existing supported language more conveniently, or may be if we are not a native speaker, it will be pain to use existing IMEs, and may be not convenient at all.

With SCIM, we can create table based input method without programming. The mechanism of using input table method with SCIM is actually just like we create shortcut for some special symbol, we mapping keyboard button to display symbol that we want.

With the assumptions that our system already have the fonts and just lack suitable IME, in my case I want to type in Javanese script (not java script :-D) it's an ancient writing system used in Java island Indonesia
First we need to do is to install the SCIM it self, you can install this package from your repository, we only need 2 packages, 'scim' and 'scim-table', in my system (using Arch Linux) I installed this package using pacman
 #pacman -Syu
 #pacman -S scim scim-tables
Then I edited the default table form /usr/share/scim/tables to suite my needed
SCIM_Generic_Table_Phrase_Library_TEXT
VERSION_1_0
### Begin Table daefinition.
BEGIN_DEFINITION
UUID = 8bcd08b9-af58-43d8-9031-b2eaf386de6a
SERIAL_NUMBER = 20131106
NAME = Javanese
ICON = /usr/share/scim/icons/Javanese.png
LANGUAGES = id_ID
AUTHOR = Andry Widya Putra
STATUS_PROMPT = JV
KEYBOARD_LAYOUT = Unknown
VALID_INPUT_CHARS = ';-,.0123456789ABCDEGHIJKLMNOPQRSTUWXYZabcdefghijklmnopqrstuwxyz)+/*\<>
### KEY_END_CHARS =
### SINGLE_WILDCARD_CHAR =
### MULTI_WILDCARD_CHAR =
SPLIT_KEYS = apostrophe
COMMIT_KEYS = space
FORWARD_KEYS = Return
### SELECT_KEYS =
PAGE_UP_KEYS = Page_Up
PAGE_DOWN_KEYS = Page_Down
### MODE_SWITCH_KEYS =
### FULL_WIDTH_PUNCT_KEYS =
### FULL_WIDTH_LETTER_KEYS =
MAX_KEY_LENGTH = 5
SHOW_KEY_PROMPT = TRUE
AUTO_SELECT = TRUE
AUTO_WILDCARD = FALSE
AUTO_COMMIT = FALSE
AUTO_SPLIT = TRUE
AUTO_FILL = TRUE
DISCARD_INVALID_KEY = TRUE
DYNAMIC_ADJUST = TRUE
ALWAYS_SHOW_LOOKUP = TRUE
USE_FULL_WIDTH_PUNCT = FALSE
DEF_FULL_WIDTH_PUNCT = FALSE
USE_FULL_WIDTH_LETTER = FALSE
DEF_FULL_WIDTH_LETTER = FALSE
END_DEFINITION
First we need to create new unique id for the table, run this command in terminal
uuidgen
Copy and paste the output to our table
UUID = 8bcd08b9-af58-43d8-9031-b2eaf386de6a
Change the serial nummber, I make it the date I create the table in YYYMMDD format
SERIAL_NUMBER = 20131106
Set the name for the icon, then copy my icon into /usr/share/scim/icons/
ICON = /usr/share/scim/icons/Javanese.png
Set the name of the table
NAME = Javanese
I commented out these variable because I don't know what the do :-D
### KEY_END_CHARS =
### KEY_END_CHARS =
### SINGLE_WILDCARD_CHAR =
### MULTI_WILDCARD_CHAR =
Changed “LANGUAGES” variable to suit your language, if you doubt this, you can fill it with en_US
LANGUAGES = id_ID
You can change the author to your name and email if you want
AUTHOR = Andry Widya Putra <andrywidyaputra@gmail.com>
I changed my status prompt to
STATUS_PROMPT = JV
Then next part is important, enter all of the valid input characters, these are the characters on our keyboard that we will map to our new special symbols. The capital letters allow us to map extra symbols by using the Shift keyboard
VALID_INPUT_CHARS = ';-,.0123456789ABCDEGHIJKLMNOPQRSTUWXYZabcdefghijklmnopqrstuwxyz)+/*\<>
For this input table I make the maximum key length to 5
MAX_KEY_LENGTH = 5
I set auto-commit to false so I can select the options of symbol from a menu
AUTO_COMMIT = FALSE
because I will choosing the symbol from the list, I set the dynamic adjust to true
DYNAMIC_ADJUST = TRUE
Next part is where we assign values for all of the keys, this is the table data. There are three values on each line and separated by tabs. The first value is the input key we press on keyboard, second value is the output (we can input unicode code from our font to map the symbol). The third values is the frequency of the symbol. We can map many characters to a single key or string. The IME will then give us a list with choices, the character with highest frequency will be at the top of the list
we should write everything between BEGIN_TABLE and END_TABLE section
BEGIN_TABLE
h     ꦲ    1
hra  ꦲꦿ    1
END_TABLE
Save it with the name we want with *.bin extension, mine is “Javanese.bin” than install it by copying it into /usr/share/scim/tables/
To start SCIM in every login (assume for all desktop environment support), add this to your profile environment (mine is /home/user/.config/openbox/environment, you can add to /home/user/.profile)
export XMODIFIERS=@im=SCIM
export GTK_IM_MODULE="scim"
export QT_IM_MODULE="scim"
scim -d
After that we need to logout, relogin and start SCIM.
That's it, our input table is ready to be used. Activate the input method by pressing Ctrl-Spacebar.
 

Review http://www.computer-issue.blogspot.com on alexa.com

0 comments:

Post a Comment