I have three keyboard layouts: English, Russian and Greek. I use first two very often, and the Greek is only needed when working on some statistical problems (from time to time). My preferred way to switch layouts is Alt+Shift. But I always need to cycle through Greek layout even when I don't really need it. Is there a way to switch between English and Russian with Alt+Shift, and to activate Greek with some other way? I'm on Linux Mint 20 Ulyana MATE (which is similar to Ubuntu Focal).
31 Answer
I have the same situation as you (often switching between 2 layouts and only rarely needing a third layout).
The way I did it is to have one script which is for switching between 2 frequent layouts:
currentLayout=$(setxkbmap -query | grep layout | awk '{print $2}')
if [ $currentLayout = "us" ]
then setxkbmap ru -option caps:escape && notify-send -t 1000 "RU"
else setxkbmap us -option caps:escape && notify-send -t 1000 "US"
fi And have another script for the third layout:
setxkbmap gr -option caps:escape && notify-send -t 1000 "GR"Then set two hotkeys for those two scripts. The way this works is if you're currently on Greek, activating the first script will switch to US (due to else statement) and then further activations of the first script toggles between US and RU.