adurante I use this solution to toggle between FR and US keyboard layout with one keystroke.
Add this function to your .bashrc
:
function keyboard {
old=$(setxkbmap -print | awk -F"+" '/xkb_symbols/ {print $2}')
if [ "$old" = "es" ]; then
setxkbmap us
else
setxkbmap es
fi
new=$(setxkbmap -print | awk -F"+" '/xkb_symbols/ {print $2}')
echo -e "Keymap is set to: $new"
echo
}
I replace fr
with es
for you. You can rename the function as you want. Then just create a keyboard shortcut in your keyboard settings to invoke the keyboard
command (or the name you choice before). Restart your terminal and test it...