A simple how to fix for LIRC with linux HTPC

Client version 1.29.1
I haven’t been able to find any information on how to get LIRC working with the latest HTPC. So I spent some time googling a solution I thought I would share.
I have tested this with the SNAP version of HTPC on ubuntu 16.04 and it works.

In the plex log (~/snap/plext-htpc/common/Logs/Plex HTPC.log) you will find an entry like LIRC socket error = 2
and then if you look in /var/log/syslog you will see that apparmor has denied snap.plex-htpc.plex-htpc access to /run/lirc/lircd wr

So I did the following:

sudo nano /var/lib/snapd/apparmor/profiles/snap.plex-htpc.plex-htpc .

#add the following line near the top, you need to include the comma

/run/lirc/lircd wr,

save the changes then rebooted. Lirc now works fine in the HTPC.
The only issue I have with it now, is it is a bit too fast on key repeats. Does anyone know of a way to set certain keys to single press and not repeat and how to add a delay to the key repeats in the LIRC.json file?

One issue that still exists is that the snap.plex-htpc.plex-htpc file is over written when there is an update. Losing the fix.

Well as a answer to my own question. I found that editing LIRC.json as follows:
“KEY_LEFT”: {“short”:“”,“long”:“left”},
“KEY_RIGHT”: {“short”:“”,“long”:“right”},
“KEY_UP”: {“short”:“”,“long”:“up”},
“KEY_DOWN”: {“short”:“”,“long”:“down”},
“KEY_BACK”: {“short”:“”,“long”:“back”},

etc… as suits yourself.

is a work around for the issue of the too fast repeats of the keys.

If you are using the Flatpak you can add an override to allow LIRC.

sudo flatpak override tv.plex.PlexHTPC --filesystem=/run/lirc/lircd

I am using the flatpak version 1.33.2. The logs show the LIRC socket now connected and inited.

Feb 14, 2023 15:24:15.409 [0x7f889114dc80] INFO - [InputManager/LIRC] LIRC socket connected
Feb 14, 2023 15:24:15.409 [0x7f889114dc80] INFO - [InputManager/LIRC] Successfully inited input

I have my inputmap at ~/.var/app/tv.plex.PlexHTPC/data/plex/inputmaps/DVICO.conf

{
  "name": "DVICO",
  "idmatcher": "DVICO*",
  "mapping": {
    "left": "left",
    "right": "right",
    "up": "up",
    "down": "down",
    "dvd_menu": "home",
    "ok": "enter",
    "back": "back",
    "playpause": "play",
    "stop": "stop",
    "mute": "pause",
    "ff": "seek_forward",
    "rew": "seek_backward",
    "more": "info",
    "skip": "step_forward",
    "replay": "step_backward",
    "alt_tab": "home",
    "ch_up": "page_up",
    "ch_down": "page_down",
    "([0-9])": "%1"
  }
}

The button names all correspond with lircrc and show correctly with irw. Plex HTPC even sees the button press but doesn’t seem to know what to do with them.

Feb 14, 2023 15:25:06.194 [0x7f889114dc80] INFO - LIRC Got Key : down, repeat count: 0, from remote DVICO_MCE
Feb 14, 2023 15:25:06.194 [0x7f889114dc80] DEBUG - [InputManager] Input received: source: LIRC keycode: down:0
Feb 14, 2023 15:25:06.194 [0x7f889114dc80] DEBUG - [InputManager] No match for: down
Feb 14, 2023 15:25:06.866 [0x7f889114dc80] INFO - LIRC Got Key : up, repeat count: 0, from remote DVICO_MCE
Feb 14, 2023 15:25:06.866 [0x7f889114dc80] DEBUG - [InputManager] Input received: source: LIRC keycode: up:0
Feb 14, 2023 15:25:06.866 [0x7f889114dc80] DEBUG - [InputManager] No match for: up

It seems the inputmap DVICO.conf isn’t getting loaded.

Any suggestions on what to try to fix this?

Thanks

Your idmatcher should to be LIRC* like is in the example LIRC.json file. The input source is LIRC and not the type of remote you are using. The remote name is only used in that log line (to provide you context).

Thank you! Guess I misunderstood article. So that got the remote working.

The problem now is that pressing a button once repeats until another one is pressed. I tried using the short and long that @MicW posted above and the long made the endless repeat stop but the repeat is too slow for some buttons and the short doesn’t work at all. I know there use to be an _LIRCUP event but that was removed from LIRC a few versions back. Any suggestions on how to make the endless repeat stop?

@brfransen
Yes I find the long is very slow, but it is better then the too fast shorts, as they are uncontrollable. I haven’t been able to find a decent middle ground for it either.

It’s actually still there. Put this in your /etc/lirc/lirc_options.conf:

release        = true
release_suffix = _LIRCUP

That didn’t work in the [lircd] section. I am using 0.10.2.

Looks like lircd release was removed back in 2017:
https://sourceforge.net/p/lirc/git/ci/beeb4adb1d114bcf5faf060b9543cc504e24a221/

Not sure what to try next.

Ah, I must’ve migrated my config from a long time ago. My lirc is new enough that it should also have obsoleted this flag so guess I had changed something else. Unfortunately a few months ago I noticed that lirc support in Linux in general was waning and essentially seeing the writing on the wall I changed to ir-keytable so I don’t have the config I used anymore.

I have moved to ir-keytable where I can but this one machine I still have this old dvico remote that I can’t get to work in ir-keytable.

Looking at this more, it appears that only the CLI options were removed but it was not removed from the config file. There are two sections in the config file which may be read depending on how exactly you are running lirc. You can confirm whether this is working by catting /var/run/lirc/lircd (or wherever the socket is set). The data sent on this socket is text readable so it’s easy to see if it is set correctly.

Oddly enough, there was actually a new release to LIRC. The previous release was in 2017 and the last (minor release) in 2022. I guess the next minor release will be in 2027 :wink:

It looks to me like the actual code in release.c and release.h was removed. Not just the CLI option.

I set those option and used irw and never got the _LIRCUP event.

There does seem to be some way to use lircd-uinput. From what I can gather right now I would need to rename buttons to input event names. I am unclear if doing that would put the UP event into the lircd socket.

I seem to remember this issue from a while ago . The fix at the time was to

#edit this file for plex infinite keypress
/etc/lirc/hardware.conf

#REMOTE_LIRCD_ARGS=""
REMOTE_LIRCD_ARGS="-r"

I probably still have that edit in place so didn’t experience the issue this time.

That is the option that has been removed so if it is still working you must have a LIRC version older than 0.10.

My solution was to rework my lircd.conf and name the buttons with KEY_ input events and then use lircd-uinput to with key up events. This made using the custom inputmap not needed.

That sounds like a good solution. I’ll look and see if I can use it on mine to fix the key speed issue

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.