Request for multilingual keyboard layout switching

I would like to use persistent DK, and US / Russian keyboard layouts. If that is impossible, switching from DK and US is mandatory for me. Even converting the system to a DK keyboard has proved daunting.


$ setxkbmap dk

works for the session, but editing /etc/rc.conf to include a line with keymap=“dk” changes nothing. I have also tried creating a login class in /etc/login.conf:


danish|danish Users Accounts:\
:charset=UTF-8:\
:lang=en_US.UTF-8:

and


# cap_mkdb /etc/login.conf

and


# pw user mod root -L danish
# pw user mod foo -L danish

which should after a reboot return:


$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_ALL=

however on NomadBSD returns:


~> locale
LANG=
LC_CTYPE=en_US.UTF-8
LC_COLLATE="C"
LC_TIME="C"
LC_NUMERIC="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_ALL=

and after all of that, I still only have a US keyboard layout available…

Hi all. I use gxkb to change keyboard from spanish (es) to english (us), but for my mistake that last layout I selectec was us-dvorak, and I have been unable to change it. In ./config/gxkb/gxkg.conf I have tried change the layout for us and every time it is changed to one of detailed in /usr/share/syscons/keymaps for (us), none is accepted and after each reboot the only keyboard layout I can use is dvorak. Of course, if I use “setxkbmap us” it runs good, but only for the current session.

I have set three input languages: English, Russian, and Lithuanian by ~/.XCompose from
/usr/local/lib/X11/locale/en_US.UTF-8/Compose
— there are all the necessary charsets in the file, including Russian (phonetic keyboard layout), with explanation.

I write in native Lithuanian without switching from English, via “Multi_key” (Alt Gray). I have set right Ctrl + Menu for Cyrillic input, and left Ctrl + left Win keyboard keys for Latin (English and Lithuanian) input.

I achieved this mode by

# setxkbmap -layout "us,us" -variant "altgr-intl,rus"
# setxkbmap -option "grp:lctrl_lwin_rctrl_menu"

commands in ~/.config/xkbdmap.sh.

1 Like

Thanks for the reply. The input languages and the commands in ~/.config/xkbdmap.sh, I understand, but the “Multi_key” (AltGR?) and how you set preferences for Ctrl + Menu (what menu? the context menu key?) and Ctrl + left on the Win keyboard are a bit of a mystery to me…

Multi_key, also known as Dead_key, Compose_key is one of a keyboard button adapted to trigger insertion of an alternate character:

Alt Gray is another [Alt] key on the right side of a keyboard, it is often applied as a Multi_key. Win — “Windows” key on a computer keyboard. And yes, Menu is the context-menu key on the right side of keyboard. Thus,

setxkbmap -option "grp:lctrl_lwin_rctrl_menu"

means ‘left Ctrl’ with ‘left Win’ for Latin, and ‘right Ctrl’ with ‘Menu’ will togle Cyrillic input.

The most of that explained in the file mentioned above:
/usr/local/lib/X11/locale/en_US.UTF-8/Compose

Xcompose key binding was discussed here last year:

1 Like

Thanks Vladas, I managed to correctly set the keyboard to US English with setxkbmap. I hope globetrotterDK manages to solve its issue.

Thanks. That will depend a bit, as I am dependent on whether I get my crashing problem sorted on my tower computer. I had also been hoping to convert my laptop (with a US / Russian keyboard) over to NomadBSD, but I have to wait until the next release of FreeBSD 13 comes out with an upgraded iwlwifi driver….

Care to post your ~/.XCompose file?

Sorry, @globetrotterdk, I am late. This is my XCompose file, although I doubt it will be clear and useful for you. All the lines starting by # sign are comments only. ## means a changed, non-default value. I have also made a separate small cheat-sheet of default accent xkeymap for myself.

### The name and location of this file:
# /home/vladas/.XCompose
#
# MS C:\Users\Vladas\.XCompose =hardlink→ C:\temp\reg\xcomposew.txt
# BSD ~/.XCompose =hardlink→ /home/vladas/registry/xcompose.txt
# USB /media/ADATA/registry/xcompose.txt and xcomposew.txt
# ~/my/zim/bsd/Home/alt-gr.txt ↔ C:\my\zim\bsd\Home\alt-gr.txt

### My settings in another config files
#
# Standard settings of BSD installation:
# /usr/local/share/X11/xkb/rules/evdev.lst
# /usr/local/share/X11/xkb/symbols/us (alt-intl at 6%, altgr-intl 35%, ru 22%)
# /usr/local/etc/X11/xorg.conf.d/10-input-keyboard.conf
# Section "InputClass"
#    Identifier      "Keyboard0"
#    MatchIsKeyboard "on"
#    MatchDevicePath "/dev/input/event*"
#    Driver          "libinput"
#    Option          "XkbRules"   "evdev"
#    Option          "XkbLayout"  "lt,us,us"
#    Option          "XkbVariant" "us,rus,altgr-intl"
#    Option          "XkbOptions" "terminate:ctrl_alt_bksp"
# EndSection
#
# /home/vladas/.config/gxkb/gxkb.cfg
# [xkb config]
# group_policy=2
# default_group=0
# never_modify_config=false
# model=pc105
## layouts=us,us
## variants=altgr-intl,rus
## toggle_option=grp:lctrl_lwin_rctrl_menu,grp:lctrl_lwin_rctrl-menu,terminate:ctrl_alt_bksp,ralt
## compose_key_position=compose:ralt
#
# /home/vladas/.config/xkbdmap.sh
# setxkbmap -model pc104 -layout us -options "" -variant basic (default map)
# setxkbmap -rules evdev -layout "lt,us,us" -variant "us,rus,altgr-intl" (at BSD installation)
## setxkbmap -layout "us,us" -variant "altgr-intl,rus" (instead of basic, intl, alt-intl)
## setxkbmap -option "grp:lctrl_lwin_rctrl_menu" (alt_shift by default)
# setxkbmap -option "compose:ralt" (this is default, or: rctrl, sclk, etc.)
#
# ~/.xprofile
## export XMODIFIERS="@im=none"

### The header part of ~/.XCompose content:
#
# include "%L" 		(locale, unnecessary)
# include "en_US.UTF-8" (unnecessary, it is from
### /usr/local/lib/X11/locale/en_US.UTF-8/Compose = universal, better than
### /usr/local/lib/X11/locale/iso8859-13/Compose  - Lithuanian local).

### Key sequences have the following form:
#
# <Multi_key> <key>… : "resulting text"
#
# All key names must be enclosed in <angle brackets>.
# The first key must be <Multi_key>.
# The remaining keys can be single characters, like <a>, <B>, <7>,
# <.>, <@>, or from the following list:
#
#  Up, Down, Left, Right (the arrow keys), space, exclam, quotedbl,
#  numbersign, dollar, percent, ampersand, apostrophe, parenleft,
#  parenright, asterisk, plus, comma, minus, period, slash, colon,
#  semicolon, less, equal, greater, at, bracketleft, backslash,
#  bracketright, asciicircum, underscore, grave, braceleft, bar,
#  braceright, asciitilde.
#
# https://babelstone.co.uk/Unicode/babelmap.html
# https://www.unicodepedia.com/
# Gucharmap - BSD app.

### Lithuanian accents for Latin letters
# (◆ means Xkey with default values, all the others are mine)
<Multi_key> <a> : "ą"			# ◆;a  ◆,a
<Multi_key> <e> : "ę"
<Multi_key> <w> : "ė"			# ◆.e
<Multi_key> <i> : "į"
<Multi_key> <o> : "ǫ"
<Multi_key> <u> : "ų"
<Multi_key> <q> : "ū"			# ◆-u  ◆bu : ŭ
<Multi_key> <Multi_key> <a> : "Ą"
<Multi_key> <Multi_key> <e> : "Ę"
<Multi_key> <Multi_key> <w> : "Ė"
<Multi_key> <Multi_key> <i> : "Į"
<Multi_key> <Multi_key> <o> : "Ǫ"
<Multi_key> <Multi_key> <u> : "Ų"
<Multi_key> <Multi_key> <q> : "Ū"
<Multi_key> <c> : "č"
<Multi_key> <s> : "š"			# ◆vs
<Multi_key> <z> : "ž"
<Multi_key> <Multi_key> <c> : "Č"
<Multi_key> <Multi_key> <s> : "Š"
<Multi_key> <Multi_key> <z> : "Ž"

### General Latin-based characters
<Multi_key> <Multi_key> <0> <a> : "Å"
<Multi_key> <Multi_key> <0> <u> : "Ů"
<Multi_key> <0> <u> : "ů"
<Multi_key> <0> <a> : "å"
<Multi_key> <2> <e> : "ә"
<Multi_key> <t> <e> : "ɛ"
<Multi_key> <t> <a> : "ɒ"
<Multi_key> <t> <o> : "ɔ"
<Multi_key> <t> <u> : "ʊ"
<Multi_key> <t> <z> : "ʒ"
<Multi_key> <Multi_key> <x> <a> : "Æ"
<Multi_key> <Multi_key> <x> <o> : "Œ"
<Multi_key> <x> <o> : "œ"
<Multi_key> <x> <a> : "æ"
<Multi_key> <l> <j> : "lj"		# ◆ng : ŋ, ◆dh ð, ◆th þ
<Multi_key> <L> <j> : "Lj"		# ◆NG : Ŋ, ◆DH Ð, ◆TH Þ
<Multi_key> <l> <l> : "ℓ"		# ◆kk : ĸ, ◆ff ff
<Multi_key> <v> <v> : "ʌ"		# ◆xx : ×
<Multi_key> <b> <s> : "ß" 		# +s ß,  +d ð,  +t þ
<Multi_key> <Multi_key> <f> : "ʃ"	# ◆fs : ſ  -not ƒ &fnof; ∫ &int;

### Other chars, spaces, punctuation
<Multi_key> <Multi_key> <p> : "§"
<Multi_key> <Multi_key> <b> : "₿"
<Multi_key> <Multi_key> <4> : "€" 	# ◆=e, ◆=c, +5
<Multi_key> <n> <r> : "№"		# ◆tm : ™
<Multi_key> <0> <c> : "℃"
<Multi_key> <0> <0> : "°" 		# &deg; (ne ◆^0 : ⁰; ◆88 : ∞ &infin;)
<Multi_key> <slash> <0> : "∅"		# diameter (/zero) &empty;
<Multi_key> <equal> <equal> : "≡"	# identical (◆~~ : ≈)
<Multi_key> <d> <d> <a> <g> : "‡"	# double dagger &Dagger; &ddag;
<Multi_key> <v> <y> <n> <s> : "♠"	# <3 : ♥
<Multi_key> <d> <z> <v> : "♦"		# *4 -nebe?
<Multi_key> <3> <3> : "♣"
<Multi_key> <1> <asterisk> : "∗"	# 1* &lowast;
<Multi_key> <2> <asterisk> : "⁑" 	# 2*
<Multi_key> <3> <asterisk> : "⁂"	# 3*
<Multi_key> <4> <asterisk> : "✢"	# 4*
<Multi_key> <asterisk> <6> : "✡"	# *6
<Multi_key> <asterisk> <5> : "☆"	# *5
<Multi_key> <asterisk> <0> : "✪"	# *0
<Multi_key> <asterisk> <asterisk> : "★" # **
<Multi_key> <4> <4> : "◆"		# ◆◆4	◆<> : ⋄;  ◆,. : ‹›;
<Multi_key> <Multi_key> <period> : "•"	# ◆◆. &bull;
<Multi_key> <backslash> <period> : "‣"	# ◆\. |>
<Multi_key> <semicolon> <o> <o> : "°͜°"
<Multi_key> <l> <f> : "( ͡° ͜ʖ ͡°)"
<Multi_key> <Left> <Right> : "↔"	# ← → &harr;
<Multi_key> <Right> <Right> : "→"	# → → and -> &rarr;
<Multi_key> <Left> <Left> : "←" 	# ← ← and <- &larr;
<Multi_key> <Down> <Down> : "↓" 	# ↓ ↓ and |v &darr;
<Multi_key> <Up> <Up> : "↑" 		# ↑ ↑ and |^ &uarr;
<Multi_key> <comma> <period> : "‹›"		# .< ir .> ; << and >> «»
<Multi_key> <Multi_key> <apostrophe> : "‛’"	# `grave and ◆''acute; en: <'> ‘’
<Multi_key> <Multi_key> <comma> : "„“"		# ◆99 and ◆66 ; en: <""> 69 “”
<Multi_key> <9> <9> : "„"			# ◆, ◆,, : "¸" fr cedille
<Multi_key> <6> <6> : "“"
<Multi_key> <minus> <minus> <space> : "— "	# ◆--- : &emdash;
<Multi_key> <Multi_key> <minus> : "‧"	# hyphenation point; · &middot;
<Multi_key> <Multi_key> <space> : " "	# and ◆_n narrow nbspace;  ◆__ &nbsp;
#<Multi_key> <space> <0> : "U+200B"	# zero width space &zwsp;
#<Multi_key> <space> <m> : "U+2003"	# wide space &emsp;
# ◆\, &thinsp;  ◆_. punctuation space &ensp;  ◆\- soft hyphen &shy;

### Greek letters
<Multi_key> <Multi_key> <t> : "ϑ"	# &thetasym;
<Multi_key> <Multi_key> <k> : "ϰ"	# ◆*.k : ϰ,  ◆*j : ξ
<Multi_key> <space> <y> : "ϒ" 		# ů Coptic ϒ „ua“ &upsih;
<Multi_key> <space> <a> : "α"
<Multi_key> <space> <b> : "β"
<Multi_key> <space> <g> : "γ"
<Multi_key> <space> <d> : "δ" 		# &delta; -not difference ∂ &part;
<Multi_key> <space> <e> : "ε" 		# &epsilon;
<Multi_key> <space> <z> : "ζ" 		# dz, zdz &zeta;
<Multi_key> <space> <h> : "η" 		# &eta;
<Multi_key> <space> <q> : "θ" 		# ◆◆t : "ϑ", ◆th : "þ", ◆_y : "ϒ"
<Multi_key> <space> <i> : "ι"		# ιωτα, γιωτα ← iauda (◆.i : ı)
<Multi_key> <space> <k> : "κ" 		# ◆◆k : "ϰ"
<Multi_key> <space> <l> : "λ" 		# &lambda;
<Multi_key> <space> <m> : "μ" 		# ◆mu miū &mu; t.p. and &micro;
<Multi_key> <space> <n> : "ν" 		# &nu;
<Multi_key> <space> <j> : "ξ" 		# gz, zgz, zgn, ngz &xi;
<Multi_key> <space> <o> : "ο" 		# &omicron;
<Multi_key> <space> <p> : "π" 		# (◆pi -defunct?) &pi;
<Multi_key> <space> <r> : "ρ" 		# &rho;
<Multi_key> <space> <c> : "ς" 		# -ieziz, -zs, -z, -s &sigmaf;
<Multi_key> <space> <s> : "σ" 		# &sigma;
<Multi_key> <space> <t> : "τ" 		# &tau;
<Multi_key> <space> <u> : "υ" 		# ū → y &upsilon;
<Multi_key> <space> <f> : "φ" 		# &phi;
<Multi_key> <space> <x> : "χ" 		# &chi;
<Multi_key> <space> <v> : "ψ" 		# psy, bzy, vzie &psi;
<Multi_key> <space> <w> : "ω"
<Multi_key> <space> <A> : "Α"
<Multi_key> <space> <B> : "Β"
<Multi_key> <space> <G> : "Γ"
<Multi_key> <space> <D> : "Δ"
<Multi_key> <space> <E> : "Ε"
<Multi_key> <space> <Z> : "Ζ"
<Multi_key> <space> <H> : "Η"
<Multi_key> <space> <Q> : "Θ"
<Multi_key> <space> <I> : "Ι"
<Multi_key> <space> <K> : "Κ"
<Multi_key> <space> <L> : "Λ"
<Multi_key> <space> <M> : "Μ"
<Multi_key> <space> <N> : "Ν"
<Multi_key> <space> <J> : "Ξ"
<Multi_key> <space> <O> : "Ο"
<Multi_key> <space> <P> : "Π"
<Multi_key> <space> <R> : "Ρ"
<Multi_key> <space> <S> : "Σ" 		# &Sigma; - not ∑ &sum;
<Multi_key> <space> <T> : "Τ"
<Multi_key> <space> <U> : "Υ"
<Multi_key> <space> <F> : "Φ"
<Multi_key> <space> <X> : "Χ"
<Multi_key> <space> <V> : "Ψ"
<Multi_key> <space> <W> : "Ω"

### My frequently-used HTML strings and sentences
<Multi_key> <Multi_key> <1> : "<!--  -->"
<Multi_key> <Multi_key> <2> : "<a href='https://www.on.lt/'></a>"
<Multi_key> <Multi_key> <3> : "<li><a href='//.lt/' rel=nofollow></a>"
<Multi_key> <n> <n> : " rel=nofollow"
1 Like

I reinstalled NomadBSD, so I had to learn the already forgotten procedure again. Some of my conclusions:

  • No need to insert the following string in ~/.xprofile (at least on default NomadBSD installation):
    export XMODIFIERS="@im=none"
  • No corrections are needed to the configuration file created during installation, although it is no longer true:
    /usr/local/etc/X11/xorg.conf.d/10-input-keyboard.conf
  • The true values of xkeyboard are stored in ~/.config/gxkb/gxkb.cfg.
  • gxkb.cfg is edited by an execution script, located at ~/.config/xkbdmap.sh. Only two strings are essential here:
    setxkbmap -layout "us,us" -variant "altgr-intl,rus"
    setxkbmap -option "grp:lctrl_lwin_rctrl_menu"

The second configuration command is for switching to an additional keyboard layout — normally that is not necessary to XKB, too. I did that for a separate Cyrillic input without the X key, but I type in the same keyboard layout in Greek, in Lithuanian, and in all Latin-based languages without switching, via the X key (multi-key, dead-key, XKB modifier).

1 Like

I did not succeed right away yet I found my mistake: I named my custom X keymap file .Xcompose, but it must be named .XCompose only, not XCompose nor .xcompose, .XCompose.txt, .XCompose.conf etc.