4

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)?

1 Answer 1

2

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

2
  • 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. Commented Jul 7, 2012 at 16:26
  • 1
    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. Commented Jul 8, 2012 at 1:59

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.