Do not work multimedia keys under GNU / Linux? Lirc will help us.

    I have a multimedia keyboard , and some keys on it do not work. To make them work, there is a manual , but everything is too confused there, so I didn’t get involved with it.
    Here we need to make a small digression:
    In addition to the keyboard, I also have a remote control. So, I somehow stumbled upon a line in the Xorg logs:
    (II) saa7134 IR (Avermedia AVerTV St: Configuring as keyboard

    those. the remote is perceived as a keyboard. And at the same time, the numeric keypad on the remote control functions normally without additional software. But since the other keys on the remote are configured through lirc , the question arose: is it possible to make non-working keys on the keyboard to work through lirc? It turned out you can! Moreover, there is even an application that has the necessary features: inputlircd. Here is a quote from man (translated for "clarity"):
    inputlircd is a small LIRC daemon that reads / dev / input / eventX from files (devices) and sends the received key codes to connected LIRC clients.
    inputlircd does not need configuration, as uses standardized names for key codes, such as those used in the kernel. Many USB remote controls that provide HID devices, like multimedia keyboards, must work right out of the box.
    In other words, this is exactly what we need :).
    Note: I configured it all under Gentoo.
    Install:

    emerge -av inputlircd

    Edit the configuration file:

    vim /etc/conf.d/inputlircd

    You can register several devices in INPUTLIRCD_OPT by separating them with a space. In my case, it turned out like this:

    INPUTLIRCD_OPTS="/dev/input/by-path/pci-0000:02:08.0-event-ir /dev/input/event4"

    In theory, it is better to specify by-path, because the number of the event (event) may change when adding / removing an input device. But for me, if you specify path for the keyboard, then the keys I needed did not work. In addition, I have two events created for the keyboard (numbered 3 and 4), and path one. And the necessary keys work only in case of event4.
    Run:

    /etc/init.d/inputlircd start

    Add to autorun:

    rc-update add inputlircd default

    Now you can check the operability using irw. To do this, simply run this utility in the terminal:

    irw

    We try the multimedia keys and get something like this in response:

    1a2 0 KEY_ZOOMIN event4
    1a3 0 KEY_ZOOMOUT event4
    8c 0 KEY_CALC event4

    Now you need to create / edit the file ~ / .lircrc. For the key shown in the example above, the following lines can be added to this file: In this example, the keys KEY_ZOOMIN and KEY_ZOOMOUT are assigned the combinations Ctrl ++ and Ctrl + -, adopted to increase and decrease, respectively. These combinations are transmitted, as you might guess, to the current window. The KEY_CALC key is assigned to start the calculator.
    begin

        prog = irxevent
        button = KEY_ZOOMIN
        config = Key ctrl-plus CurrentWindow
    end
    begin
        prog = irxevent
        button = KEY_ZOOMOUT
        config = Key ctrl-minus CurrentWindow
    end
    begin
        prog = irexec
        button = KEY_CALC
        config = kcalc
    end

    You can read about irexec and irxevent in man'ah or here .
    Thus, you can make any multimedia keys work.

    Also popular now: