📜 ⬆️ ⬇️

Multimedia keys do not work 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 must make a small digression:
In addition to the keyboard, I also have a remote control. So, I 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 while the digital keyboard on the remote functions normally without additional software. But since the rest of the keys on the remote are configured via lirc , the question arose: can the non-working keys on the keyboard be made to work via lirc? It turned out you can! Moreover, there is even an application that has the necessary capabilities: inputlircd. Here is a quote from man'a (translated for "clarity"):
inputlircd is a small LIRC daemon that reads / dev / input / eventX from files (devices) and sends the received codes to the keys of connected LIRC clients.
inputlircd does not need a configuration, because uses standardized names for key codes, such as those used in the kernel. Many USB remotes that provide HID devices, like multimedia keyboards, should work right out of the box.
In other words, this is exactly what we need :).
Note: I set it up under Gentoo.
Install:

emerge -av inputlircd

Editing 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 the by-path, since event number (event) may change when adding / removing an input device. But for me, if I specify the path for the keyboard, then the keys I needed did not work. In addition, I have two events for the keyboard (numbered 3 and 4), and path one. And the necessary keys work only in the case of event4.
Run:

/etc/init.d/inputlircd start

Add to autostart:

rc-update add inputlircd default

Now you can test the performance with irw. To do this, simply run this utility in the terminal:

irw

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

1a2 0 KEY_ZOOMIN event4<br/>1a3 0 KEY_ZOOMOUT event4<br/>8c 0 KEY_CALC event4<br/>
Now you need to create / edit the file ~ / .lircrc. For the keys above, you can add the following lines to this file:
begin
<br/> 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

In this example, the keys KEY_ZOOMIN and KEY_ZOOMOUT are assigned the combination Ctrl + + and Ctrl + -, which are accepted for increasing and decreasing, respectively. These combinations are transmitted, as it is not difficult to guess, to the current window. The KEY_CALC key is assigned to start the calculator.
About irexec and irxevent can be read in man'ah or here .
Thus, you can make any multimedia keys work.

Source: https://habr.com/ru/post/53184/


All Articles