如何改变键盘布局(一X11 API解决方案) [英] How to change Keyboard Layout (a X11 API solution)

查看:359
本文介绍了如何改变键盘布局(一X11 API解决方案)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过编程可以改变键盘布局在Linux中,
什么X11的API函数做到这一点?

I want to change keyboard layout in Linux by programming, What X11's API function does this?

推荐答案

我找到了一个很好的解决方案。
这是周杰伦布罗姆利wrriten一个C ++类,我可以添加到我的应用程序,并使用它。

I found one good solution. It's a c++ class wrriten by Jay Bromley, that I can add to my app and using it.

源$ C ​​$ C

这是非常容易使用:

#include "XKeyboard.h"

XKeyboard xkb;

std::string cGrpName=xkb.currentGroupName(); //return somethings like "USA"
std::string cGrpSymb=xkb.currentGroupSymbol(); //return somethings like "us"

xkb.setGroupByNum(0);//set keyboard layout to first layout in available ones

您可以阅读源$ C ​​$ c和发现了一些其它有用的功能。
编译独立版本,你需要取消的意见诠释的主要功能$ P $的XKeyboard.cpppsent(或写自己的main.cpp)和使用出头是这样的:

you can read source code and found some another useful functions. for compiling standalone version you need to un-comments "int main" function present in "XKeyboard.cpp" (or write your own main.cpp) and use somethings like this:

g++ *.cpp -o getxkblayout -L/usr/lib -lX11

这篇关于如何改变键盘布局(一X11 API解决方案)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆