How to get current gnome keyboad layout from terminal

Posted by ftiaronsem on Ask Ubuntu See other posts from Ask Ubuntu or by ftiaronsem
Published on 2012-06-25T17:50:17Z Indexed on 2012/07/02 9:23 UTC
Read the original article Hit count: 347

Filed under:
|

For usage in a bash script, I need to get the gnome keyboard layout the user is currently using. For example if the user sets its keyboard layout to en-us , I need a bash command that prints me this.

How can I get that information?

Update:

setxkbmap -query is unfortunatelly not working. Below is the ouput with the en (first command) and the de (second command) layout activated. Switching keyboard layout seems to be have some relation with gnome session configuration

setxkbmap -query 
rules:      evdev
model:      pc105
layout:     us,de
variant:    ,
options:    terminate:ctrl_alt_bksp,lv3:ralt_switch,grp:alts_toggle

setxkbmap -query
rules:      evdev
model:      pc105
layout:     us,de
variant:    ,
options:    terminate:ctrl_alt_bksp,lv3:ralt_switch,grp:alts_toggle

© Ask Ubuntu or respective owner

Related posts about bash

Related posts about keyboard-layout