DormanResearch : KeyboardLayout

Referers: Keyboard :: SpecialCharacters :: (Remote :: Orphans :: Tree )
Dorman Wiki
Dorman Lab Wiki

0ibus

ibus  is the new input method for entering text via a keyboard.  It took quite a bit of investigation to get it working on Ubuntu.  First, install ibus, ibus-gtk, ibus-m17n, ibus-qt4, and im-switch to make sure it works with all kinds of applications.  Then, as a regular user, run im-switch -s ibus to make ibus your input method.  Log out and back in (no reboot required).  Now, ibus-daemon should be running with a keyboard icon in the system tray.  You can click on the icon and select Preferences to add new input methods.  Always remember to restart the daemon if you change the input methods.  Once you have input methods, you can use the icon to change the current input method.  Alternatively, you can use ctrl+space to toggle to/from the current input method.  By default, alt+shift_L switches between multiple IM once the input method is activated, but I changed it to ctrl+shift_L.

0ibus-table
ibus-table provides a way to use arbitrary key mappings.  Simple text files are converted to sqlite databases that can be loaded by ibus-table into ibus.  In this way, the IPA  symbols are available (in Ubuntu 11.04 or later as package ibus-table-others, but also downloadable as source and usable in earlier releases) via the x-sampa  ibus table.  In addition, many LaTeX symbols are available via the ibus LaTeX table.  LaTeX symbols typically require more typing, but many of us are familiar with the codes.  Further, a download of the source will provide latex.txt, to which new symbols can be easily added, then make, then overwrite the existing latex.db with the newly compiled one.  Finally, ibus-table provides the Compose method, which is somewhat like typing with dead keys for ibus.

0kbmap

setxkbmap -rules evdev -model evdev -layout us -variant altgr-intl
setxkbmap -option grp:switch,grp:alt_shift_toggle,grp_led:scroll "us(basic),us(altgr-intl)"

The first command sets the keyboard model to PC104 with US layout and variant altgr-intl invented in 2007 by a user sick of dead keys.  The next command sets up the alt+shift to switch between two keyboard layouts (US basic variant and US altgr-intl variant).  altgr (right alt key) is like another shift key that produces additional symbols.  For example alt+5 produces the Euro sign under the altgr-intl variant.

An alternative uses dead keys and used to be the way I did things before I found the above method.  You can switch between all three with:
setxkbmap -option grp:switch,grp:alt_shift_toggle,grp_led:scroll "us(basic),us(altgr-intl),us(intl)"

setxkbmap -model pc105 -layout us -variant intl
setxkbmap -option grp:switch,grp:alt_shift_toggle,grp_led:scroll "us(basic),us(intl)"

The first command sets the keyboard model to PC105 with US layout and variant intl.  This particular variant defines dead keys and altgr.  The next command sets up the alt+shift to switch between two keyboard layouts (US basic variant and US international variant).  altgr (right alt key) is like another shift key that produces additional symbols.  For example alt+5 produces the Euro sign under the intl variant. This variant also defines dead keys, such as , ', and ^, which output nothing, but when followed by an appropriate character, modify it in some natural way.  For example, ^+6 produces a superscript 6.  Or, ^+e, produces an 'e' with a carrot atop it.  These last examples don't always seem to work!

Figuring out how to use setxkbmap is tricky.  The manpage sucks.  You can see a complete list of keyboard models, layouts, and options in /usr/share/X11/xkb/rules/evdev.lst.

0Key Mappings
See /usr/share/X11/xkb/symbols/us for the key mappings for each layout, divided into files with the name of the layout (e.g. us) and variants, defined within the same file.  Each key is identified by a unique code.  The alphanumeric keyboard (qwerty) is identified by A, followed by letter, A-E, counting from bottom row (with space bar) up to the row of numbers, then two digit number indicating key's location counting left across the row and ignoring special keys like TAB or CAPS_LOCK.  Thus, key AE07 is the '7' key.  Other parts of the keyboard are similarly defined.  For example, the function keys are prefixed with FN.  Next, there are up to four symbols mapped to each key.  The first is the code output if the key is simply struck.  The second is output if the key is struck with SHIFT.  Often these are the only key mappings.  If the altgr key is defined (ralt_switch), then ALT_R switches to composition mode so multiple keys combine to produces letters with diacritics.  Some keymappings may also use dead keys to do compositions.  Dead keys do nothing when typed, but resolve to letters with diacritic markings when followed with an appropriate keystroke.  Dead key shift+~ gives tilda,  and ' give accents, RALT+- gives flat line, RALT+shift+- gives dot underneath, etc.

0Layouts

US International Keyboard Layout [graphic]
Probhat Bengali Keyboard Layout [graphic]

0My Setup

• ibus underlies everything
• ctrl+space activates Bengali keyboard
• ctrl+shift_L switches to other keyboards (like Chinese or IPA or Composition)
• alt+shift toggles US layout vs. US International layout via kbmap.

See SpecialCharacters for information more on entering symbols.