Ubuntu: 如何使用C++、gtk或xkb获取活动键盘的名称

huangapple go评论71阅读模式
英文:

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:    ,

huangapple
  • 本文由 发表于 2023年6月6日 15:44:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76412426.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定