On 4/6/24 18:38, Andrew Udvare wrote:
On Sat, 6 Apr 2024 at 21:32, Daniel Frey <djqf...@gmail.com> wrote:
What's even stranger is if I manually start it and restart lircd it works!

Have you tried adding Before=lircd.service in the [Unit] section?


OK, I have finally sorted out the IR keymap/lircd/irexec/LCDd problems.

It turns out the systemd units as shipped just simply do not work, at least for my hardware.

The custom unit I made to apply a new keytable and protocol change was working fine. After a lot of reading about systemd units and also poring through logs, I discovered udev was triggering something related to the LCD/IR module - my custom unit was running before this happened but the udev trigger reset it to defaults (for whatever reason.)

In order to fix that, I had to change my unit to this:

[Unit]
Description=Add custom keymap to iMon remote
Requires=systemd-udevd.service systemd-udev-settle.service systemd-udev-trigger.service After=systemd-udevd.service systemd-udev-settle.service systemd-udev-trigger.service
Before=lircd.service inputlircd.service irexec.service

[Service]
RemainAfterExit=true
ExecStart=/usr/bin/ir-keytable -c -p rc-6 -w /etc/rc_keymaps/imon_mce.toml

[Install]
WantedBy=multi-user.target
RequiredBy=lircd.service irexec.service


This made the keymap change work reliably.

After this lircd was working normally.

I use lircd so I can use irexec to listen for the power button and just shut the computer off. Kodi is too finicky and just wouldn't turn off or it would just logout, even with the polkit policy in the wiki applied.

Now, starting irexec didn't work the the shipped systemd unit either, it would just exit and not stay running. I fixed that with this custom unit:

[Unit]
Documentation=man:irexec(1)
Documentation=http://lirc.org/html/configure.html
Documentation=http://lirc.org/html/configure.html#lircrc_format
Description=Handle events from IR remotes decoded by lircd(8)
After=lircd.service
Requires=lircd.service

[Service]
; user=lirc
; group=lirc

; Hardening opts, see systemd.exec(5).  Doesn't add much unless
; not running as root. If these are applicable or not depends on
; what commands irexec.lircrc invokes.
;
; NoNewPrivileges=true
; MemoryDenyWriteExecute=true
; PrivateTmp=true
; ProtectHome=true
; ProtectSystem=full


Type=forking
ExecStart=/usr/bin/irexec --daemon /etc/lirc/irexec.lircrc

[Install]
WantedBy=multi-user.target


So irexec would start and actually stay running. I did also tell it to start after lircd (although I'm not 100% sure this matters - it may not.)

Of course the LCD unit wouldn't start and stay running either, again the systemd unit shipped didn't work so I customized it:

[Unit]
Description=LCDProc (LCDd)
After=network-online.target lircd.service
Requires=lircd.service

[Service]
ExecStart=/usr/sbin/LCDd -c /etc/LCDd.conf
Type=forking

[Install]
WantedBy=multi-user.target

After all this, then Kodi wouldn't start up. I figured out quickly this was caused by lightdm starting before the network was ready, fixed with this custom unit:

[Unit]
Description=Light Display Manager
Documentation=man:lightdm(1)
After=systemd-user-sessions.service
After=network-online.target
Wants=network-online.target

[Service]
ExecStart=/usr/sbin/lightdm
Restart=always
IgnoreSIGPIPE=no
BusName=org.freedesktop.DisplayManager

[Install]
Alias=display-manager.service


Hopefully this may be helpful to others with HTPCs switching to systemd from openrc. In openrc nearly all of this customization isn't needed - I only modified /etc/init.d/lircd in openrc in order to load the keymap before lircd started.

Dan

Reply via email to