I'm on KDE and I need to find out and to be able to switch current global keyboard layout in a script. I've made a research on setxkbmap
- but in this case it's of no help.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Found a solution:
setxkbmap -print | grep xkb_symbols | awk '{print $4}' | awk -F"+" '{print $2}'
to find out current layout. The following allows to set it:
setxkbmap -layout us
setxkbmap -layout ru
and this toggles 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 can't cope with all this, but standard Kubuntu layout indicator works fine.