Making a keyboard layout using IBus
IBus provides a range of input methods for linux. One of the easiest ways to develop a new keyboard layout for linux is to use IBus's m17n module.
Using IBus m17n
- If on your own system, first install IBus and the m17n module (see below—not needed on lab machines):
- Enable IBus as your default input method:
im-config -n ibus
- Restart X11 (log out and log back in, or potentially just
xfwm4 --replace && xfce4-panel -r &), and you should have a hard-to-see language switcher icon somewhere near the time on your panel.
- If you don't seen the icon, try adding the notification area to your panel. Right click on the edge of the panel, click "Add new items", and find "status tray plugin" (formerly "notification area").
- If that doesn't work, open a terminal, and run
- Right click on that icon and click preferences. Go to the "Input Method" tab and you can add various keyboard layouts. Note that you have to press the "..." button at the bottom to see all the categories supported, and that there are a lot of layouts hidden under the various categories.
- You'll have to configure a "next layout" key combination that makes sense for you. Sometimes the key combination isn't completely obvious to set.
- If you want to be able to use an AltGr key, then you'll need to go into your session manager preferences (in XFCE, Menu → Settings → Keyboard) and add a layout with AltGr enabled (Layout tab, Add, "English (international, with AltGr deadkeys)"). You'll also need to make sure that your keyboard layout switching key combo doesn't involve Alt, or that will get caught and not pass an AltGr press through to iBus.
- In Cinnamon and maybe Gnome (e.g., on your own computer—but not on XFCE on the lab computers), you may be able to simply set which key is AltGr (usually right alt) in keyboard settings.
- If you need to install IBus on your own system, try this (Debian-derivatives only, like Ubuntu):
sudo apt-get install ibus-m17n
Developing a keyboard layout for IBus m17n
- You should be able to copy a file in
/usr/share/m17n/to a different name and modify it to your liking. The layout files have the extension
- Put your new
~/.m17n.d/. If it doesn't exist, make it by running
- Your file will need these three elements at the top to correctly show up in ibus:
(input-method lg keyboard-name)- replace
lgwith the two letter ISO code for your language. If there is no two letter code, just use
keyboard-namewith the name for your keyboard.
(description "This is a keyboard for xyz designed for ling073! Documentation available @ [link to wiki]")
(title "Keyboard Name")
- Your keyboard layout will show up under the language if there is already an entry for it. If there isn't, it will show up under "other."
- If you're sure everything is right, but it isn't showing up, there is likely (but not certainly) a parsing error in your
- You'll probably need to restart IBus for the new file to become available or for any further modifications to it take effect: right click on the hard-to-see IBus icon and click "restart".
Gstands for AltGr. See how
pa-jhelumlayout uses it.
- You can store a list of keys typed in a variable and do fancy things with it. See how
kolayouts do it.
- If you really want compose key, you may need to fiddle some. I have some ideas, so talk to me if this is something you want to pursue.
- To set your default keyboard back to the regular input method, you can do the following:
im-config -n xim
- To count the frequency of characters in a corpus, you can do something like this:
grep -o '\w' textfile.txt | sort | uniq -c | sort -n
- (don't forget to replace
textfile.txtwith the name of the file that you're checking—probably the file you have with the most text in the language)
- (don't forget to replace
- If you prefer descending order, just add an
grep -o '\w' textfile.txt | sort | uniq -c | sort -nr
- If you want it to include non-alphabetic characters, you can do the following:
grep -Po '[\w\W]' textfile.txt | sort | uniq -c | sort -n
- There's another approach to developing keyboard layouts for iBus, but it may require admin privileges to install—I haven't tested it.
- A good way to make custom compose key sequences.