XKB and keyboard layouts on Linux

:linux:

For a while I was looking for an efficient way to deal with Lithuanian letters and english keyboard at the same time. I have noticed that switching between keyboard layouts with Super+Space (or any other keys combination) is not efficient. Sometimes I even do not recognize when I switch to different layout and start typing code. Or jump from chat to vim and instead of special symbols lithuanian letters are written. I knew that solution should be a consistend and one layout.

After asking few folks how they are dealing with this situation - majority of answers (from those who answered) were using AltGr (right Alt) key to type symbols from yet another layout. Usually standard lithuanian layout is turned on (with letters on numbers row). And numbers a reached with AltGr+. For me, coder, this sounded suboptimal as to type special symbols like “=” I would need wreck my fingers trying to type three keys combination like AltGr+Shift+=. Another option - use “US Keyboard (with Lithuanian letters)” layout also known as “lt,us”.

For some reason on Ubuntu 20.04 only “Lituanian” layout was available via UI which is the standard one also known as “lt,lt”. Custom layount can be loaded via command line so I’ve tried:

$ setxkbmap -layout lt,lt -variant ,us

Typing setxkbmap -print -verbose 10 showed the layout is loaded but it seems Gnome overrides xkb settings at some level. Following command solved the issue:

$ gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'lt+us'), ('xkb', 'lt+us')]"

Links: