Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

325
Vistas
get current active keyboard layout(language) in linux

In my C/C++ program I want to know which language is user going to type. I mean the language whose ID is displayed in the corner of the task bar. Like EN or RU or ZH or FR or IT.

I know how to get the list of possible layout:

$ setxkbmap -query | grep layout

output:

layout:     us,ru

But how to know which one is selected right now? (for the current window)

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

setxkbmap -print isn't helpful in this case, which was also my first idea. I have found a little tool, very easy to 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 you can run the command ./xkblayout-state to get the current layout, e.g.

./xkblayout-state print "%n"                          
German%

or list all installed layouts

./xkblayout-state print "%N"
German
English
English

In this case without a trailing %. I would have expected that, because I have not added a \n.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda