英文:
Ubuntu: How to get the name of the active keyboard using C++ gtk or xkb
问题
我正在使用代码(C ++,ubuntu,gdk,xkb),在设置->键盘->输入源中,我使用的是德语键盘,它位于列表的顶部。
在我的程序中,我可以访问用于顶部语言的键码、键值和键映射;(如果我更改语言,我会得到不同的结果 - 这是可以的,当然应该这样工作)
现在在我的C++程序中,我想访问活动键盘的名称,如"german"或"french"。如何使用C++、gdk或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
答案1
得分: 1
对于Ubuntu,你可以从 /etc/default/keyboard 中查看:
$ cat /etc/default/keyboard
XKBLAYOUT="us"
BACKSPACE="guess"
XKBMODEL="pc105"
XKBVARIANT=""
XKBOPTIONS=""
或者使用 setxkbmap 命令:
$ setxkbmap -query
rules: evdev
model: pc105
layout: us,us
variant: ,
英文:
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: ,
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论