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

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

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

  1. 对于Ubuntu,你可以从 /etc/default/keyboard 中查看:
  2. $ cat /etc/default/keyboard
  3. XKBLAYOUT="us"
  4. BACKSPACE="guess"
  5. XKBMODEL="pc105"
  6. XKBVARIANT=""
  7. XKBOPTIONS=""
  8. 或者使用 setxkbmap 命令:
  9. $ setxkbmap -query
  10. rules: evdev
  11. model: pc105
  12. layout: us,us
  13. variant: ,
英文:

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

  1. $ cat /etc/default/keyboard
  2. XKBLAYOUT="us"
  3. BACKSPACE="guess"
  4. XKBMODEL="pc105"
  5. XKBVARIANT=""
  6. XKBOPTIONS=""

Or use the setxkbmap command:

  1. $ setxkbmap -query
  2. rules: evdev
  3. model: pc105
  4. layout: us,us
  5. 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:

确定