How to add a keyboard layout on Linux that supports Arabic, Persian, and Urdu.
Take a look at src/my_ara
to check out the layout.
-
SHIFT
is the level-1 modifier -
AltGr
is the level-2 modifier (for adding dagger-alef, urdu/Persian characters, etc.) -
SHIFT+AltGr
is the level-3 modifier (for adding diacritical hamza, diacritical, maddah, etc.)
- sudo edit
/usr/share/X11/xkb/symbols/ara
- Copy-paste keyboard layout from
src/my_ara
to end of file.
- Copy-paste keyboard layout from
- sudo edit
/usr/share/X11/xkb/symbols/nbsp
- Copy-paste "no-break-space" description from
src/my_nbsp
to end of file.
- Copy-paste "no-break-space" description from
- sudo edit
/usr/share/X11/xkb/rules/evdev.xml
- Copy-paste the "variant" from
src/my_evdev.xml
and add as additional variant to "ara" layout after "azerty", "qwerty", "buckwalter", etc.
- Copy-paste the "variant" from
CTRL-ALT-BACKSPACE
to restart X or log-out and log back in.- Find Keyboard layout settings in Desktop settings/configuration.
- Add "Arabic-Persian-Urdu (Custom)" from "Arabic" selection
- Pick suitable key to switch layouts. I choose
CAPS LOCK
.
On his blog, Andreas Hallberg describes a methodolody for BiDi (RTL and LTR) editing in vim. This uses Arabic keymap binding within vim so that it doesn't affect vim commands.
The vim keymap file arabic-pc_utf-8.vim
for my Mac based keyboard layout is in the directory vim-keymap
.
Andreas's Windows based keyboard layout is in his repo: https://github.com/andreasmhallberg/dotfiles/blob/master/arabic-pc_utf-8.vim
For neovim on MacOS , place this file in $HOME/.config/nvim/keymap/
.
For vim, place it in $HOME/.vim/keymap/
.
On MacOS, terminal vim (installed using Homebrew) did not work with :set rightleft
. But neovim on iterm2 worked. For iterm2, in order to use the Mac option key as the Meta modifier key in neovim, go to iterm2's Settings > Profile > Keys, and select the option to use the option keys as "Meta".