Let’s say you have 3 languages on your linux machine: English, Russian and Belarusian. You frequently switch between EN and RU. Sometimes you write something in EN and BY. So you don’t want to press Alt+Shift three times constantly, only when writting something in Belarusian.
Here I assume that
Alt+Shift switches languages inside a group.
Save the scipt in
toggle_en_ru.sh (for example).
Add execution permissions.
sudo chmod +x /usr/local/bin/toggle_en_ru.sh
Go to keyboard layouts settings and add a new shortcut. Assign a shortcut for switching between languages groups. I decided to use
Win+Space for language pairs (EN/RU
<-> EN/BY) switching.
Querying existing configuration
Switch keyboard layout from command line
xkblayout-state - works for me.
git clone https://github.com/nonpop/xkblayout-state.git cd xkblayout-state/ make
xkblayout-state set +1
Now I can use the same method of assigning a custom keyboard shortcut for that command and have layout switching by pressing
Super+Space for example.
xkb-switch - I couldn’t compile it fast enough on my Linux Mint 17