Arabic keyboard in OpenBSD: how to install / use?


Hi! I had a quick question, hopefully painless one for you all. I’m running OpenBSD 6.3. I switch between a mix of desktop (dwm through startx) and terminal. I’m trying to figure out how to install and use an Arabic keyboard layout / encoding with BSD. Specifically, I want to be able to write in Arabic in emacs and in my web browser (for starters).

When I run kbd -l it doesn’t seem to me like any of those are Arabic keyboard layouts. But I’m not sure if that’s the right approach to be taking. Do I need to install a custom layout? Or is it a matter of finding the right fonts? Anyone have any idea about this, even in general terms about an approach I might take? Thanks!

It seems unlikely that OpenBSD would offer Arabic as one of its predefined keyboard layouts, but I’m wondering whether that means I’ll have to do my own custom mapping using unicode / UTF-8?


@jggimi probably knows answer to your question. :slight_smile:


I’ve figured out the answer to my own question :slight_smile:
I ended up using setxkbmap ara to change the keyboard. I can’t use Arabic in the console / tty, but in X I can. I ideally want to be able to switch between the two keyboards easily, and I do that by adding the following to my ~/.xinitrc file:

setxkbmap -layout us,ara -option grp:alt_space_toggle

So now when I’m in X, I can just press alt-space and it’ll switch the layout. There are some other options / key combinations possible in the -option option, but I’m not sure where those are written up.


Nice :yum:
Don’t you have something similar to this in OpenBSD? Hacking wscons to add a keymap

If your favourite keymap is not supported, you can start digging in src/sys/dev/wscons/wsksymdef.h and src/sys/dev/pckbport/wskbdmap_mfii.c to make your own. Be sure to send-pr a change-request PR with your work, so others can make use of it!

You can test your keymap by using wsconsctl instead of directly hacking the keymaps into the keyboard mapping file. For example, to say keycode 51 without any modifiers should map to a comma, with shift it should map to a question mark, with alt it should map to a semicolon and with both alt and shift it should map to colon, issue the following command:

wsconsctl -w “map += keycode 51=comma question semicolon colon”


Yes I think we have that, but the setxkbmap worked well enough for now


setxkbmap works for xorg
wscons is for the console, but… I understand… mapping every singel key would be a PITA!


Have also a look at -variant switch for setxkbmap(); all models/variants/options descriptions are listed inside /usr/X11R7/share/X11/xkb/rules/base.lst; here’s a nice write up on advanced X kbd(4) tuning

EDIT: xmodmap(1) is also your friend, can do amzing things on weird keyboard layouts such as those of Chromebooks and Pinebooks