KDE: how do I find and switch the current global keyboard layout from the CLI?

I am in KDE and I need to find out and be able to switch the current global keyboard layout in a script. I did the research setxkbmap, but in this case it did not help.

+2
source share
1 answer

Found a solution:

setxkbmap -print | grep xkb_symbols | awk '{print $4}' | awk -F"+" '{print $2}'

to find out the current layout. The following allows you to install it:

setxkbmap -layout us
setxkbmap -layout ru

and this switches it:

if [ `setxkbmap -print | grep xkb_symbols | awk '{print $4}' | awk -F"+" '{print $2}'` = us ] ;then echo "EN"; echo "changing to RU..."; setxkbmap ru ; else echo "RU"; echo "Changing to US..."; setxkbmap us ; fi

If you use gxneur, it cannot handle all of this, but the standard Kubuntu build indicator is working fine.

+5
source

Source: https://habr.com/ru/post/1524721/


All Articles