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

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -