tags:

views:

315

answers:

1

Hi guys, are there any libraries for linux wroted in C++ which could register global hotkeys for my application? Thanks.

+3  A: 

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.

ephemient