get current active keyboard layout(language) in linux -
in c/c++ program want know language user going type. mean language id displayed in corner of task bar. en or ru or zh or fr or it.
i know how list of possible layout:
$ setxkbmap -query | grep layout
output:
layout: us,ru
but how know 1 selected right now? (for current window)
setxkbmap -print
isn't helpful in case, first idea. have found little tool, easy compile
sudo apt-get install git mkdir -p `~/src` cd `~/src` git clone https://github.com/nonpop/xkblayout-state.git cd xkblayout-state make
now can run command ./xkblayout-state
current layout, e.g.
./xkblayout-state print "%n" german%
or list installed layouts
./xkblayout-state print "%n" german english english
in case without trailing %
. have expected that, because have not added \n
.
Comments
Post a Comment