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

时光总嘲笑我的痴心妄想 提交于 2019-12-01 08:04:45

问题


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.



来源:https://stackoverflow.com/questions/7021111/kde-how-do-i-find-and-switch-current-global-keyboard-layout-from-cli

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!