Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the best way to implement hotkeys support in Linux (ie support for brightness, audio or keyboard backlight keys)? By "best way" I mean robust, without code duplication, with minimal work required to add support for new hardware.

  1. Who should capture the hotkeys? Kernel module / daemon / X server / desktop environment / something else?
  2. Who should do the actual work (e.g. setting brightness)?
share|improve this question

Setting custom key bindings is already supported by most Linux window managers. You can also get xorg input drivers that recognize things like media and brightness keys. What window manager / desktop environment are you currently using, and what exactly are you trying to do? If you are just trying to get the brightness keys working, you can go into your window manager's keyboard settings, go to keyboard shortcuts, and bind the keys to raise and lower brightness, assuming your window manager has built in support for these two operations. If it doesn't, you can install xbacklight and bind the raise brightness key to xbacklight -inc 1 and the lower brightness key to xbacklight -dec 1.

See http://linux.die.net/man/1/xbacklight

share|improve this answer
I was trying to fix an issue in pommed (daemon taking care of hotkeys and some other things in macbooks). But I lost motivation because I realized that what pommed is doing is a bit "hacky". So I'm trying to find out if there's some "right". The problems with window manager taking care of hkeys are 1) it doesn't work in full screen games, in login manager or in virtual terminals 2) code duplication across different WMs. – fhucho Jul 7 '12 at 16:26
Okay, so you want to implement a program that responds to specific keys across WMs. Sounds like you should write an X client program that reads key events.Take a look at tronche.com/gui/x/xlib. Chapter 10 and 11 specifically have the info you need. – Zhehao Mao Jul 8 '12 at 1:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.