are there any libraries for linux wroted in C++ which could register global hotkeys for my application? Thanks.
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
I wrote a simple C library a while back to make registering global X11 hotkeys a little less painful. There are some examples with the code. You can get it at:
https://github.com/jwmcode/xhklib/
You'll have to provide more information.
In Gnome, the global functionality varies by window manager. Metacity has configurable global shortcuts, as do Compiz and Sawfish, and they're all configured differently. Xhotkeys can also be used for the same functionality. However, these are all limited to starting applications only.
Within the KDE application framework, KAction can register global shortcuts which perform actions inside your program. These are actually handled by a module in kded (launched on demand), so they work even outside of the KDE desktop environment.
If you don't use the KDE framework, but are still using X11, you can use the xlib API to call XGrabKey on the root window.
For shortcuts that work outside of X, as long as you are running as root (or permissions are changed permissively) on a 2.6 kernel, you can directly open
/dev/input/event*
, and poll for the desired key events.