user3443063
user3443063

Reputation: 1623

Ubuntu: How to get the name of the active keyboard using C++ gtk or xkb

I am working with code( C++, ubuntu, gdk, xkb) where I use a german Keyboard which is on the top of the list in settings->Keyboard->input sources .

In my program I can access the keycode, keyval, keymaps used for the language which is on top of that list; (if I change the language I get different results - which is fine and of course should work this way)

Now in my C++ program I want to access the name of the active keyboard like "german" or "french". How can I access the name of the active keyboard using c++ gdk or xkb

Upvotes: 0

Views: 134

Answers (1)

qianfg
qianfg

Reputation: 898

For Ubuntu, you can read it from /etc/default/keyboard:

$ cat /etc/default/keyboard
XKBLAYOUT="us"
BACKSPACE="guess"
XKBMODEL="pc105"
XKBVARIANT=""
XKBOPTIONS=""

Or use the setxkbmap command:

$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     us,us
variant:    ,

Upvotes: 1

Related Questions