Skip to content

Commit 6df000c

Browse files
committed
fix: properly detect receiver before service start
1 parent 585e948 commit 6df000c

2 files changed

Lines changed: 25 additions & 18 deletions

File tree

daemon/infrafid.service

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ After=network.target
44
Wants=network.target
55
[Service]
66
Type=simple
7-
ExecCondition=/bin/sh -c 'ls /dev/lirc* >/dev/null 2>&1'
8-
ExecStart=/usr/local/bin/infrafid --foreground
7+
EnvironmentFile=-/etc/default/infrafid
8+
ExecStart=/usr/local/bin/infrafid --foreground $INFRAFID_ARGS
99
Restart=on-failure
1010
RestartSec=5
1111
StartLimitBurst=3

daemon/install.sh

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,32 @@ if [ "$(id -u)" -ne 0 ]; then
1111
exit 1
1212
fi
1313

14-
# Check for LIRC device
15-
if [ ! -e /dev/lirc0 ]; then
16-
echo "Warning: /dev/lirc0 not found. The daemon will fail to start without it."
17-
echo "Ensure your IR receiver is connected and the kernel module is loaded."
14+
# Detect input mode — LIRC vs evdev
15+
HAS_LIRC=false
16+
if ls /dev/lirc* >/dev/null 2>&1; then
17+
HAS_LIRC=true
1818
fi
1919

20-
# Configure IR receiver for RC-6 only
21-
RC_DIR="/sys/class/rc/rc0"
22-
if [ -d "$RC_DIR" ]; then
23-
echo "Configuring IR receiver for RC-6 protocol..."
24-
echo rc-6 > "$RC_DIR/protocols"
25-
echo " Active protocols: $(cat "$RC_DIR/protocols")"
26-
27-
# Persist via udev rule so it survives reboot
28-
UDEV_RULE="/etc/udev/rules.d/99-infrafid-rc6.rules"
29-
echo 'ACTION=="add", SUBSYSTEM=="rc", ATTR{protocols}="rc-6"' > "$UDEV_RULE"
30-
echo " Created udev rule: $UDEV_RULE"
20+
if [ "$HAS_LIRC" = true ]; then
21+
# Configure IR receiver for RC-6 + NEC (both supported via LIRC)
22+
RC_DIR="/sys/class/rc/rc0"
23+
if [ -d "$RC_DIR" ]; then
24+
echo "Configuring IR receiver for RC-6 and NEC protocols..."
25+
echo "rc-6 nec" > "$RC_DIR/protocols"
26+
echo " Active protocols: $(cat "$RC_DIR/protocols")"
27+
28+
# Persist via udev rule so it survives reboot
29+
UDEV_RULE="/etc/udev/rules.d/99-infrafid-rc6.rules"
30+
echo 'ACTION=="add", SUBSYSTEM=="rc", ATTR{protocols}="rc-6 nec"' > "$UDEV_RULE"
31+
echo " Created udev rule: $UDEV_RULE"
32+
else
33+
echo "Warning: $RC_DIR not found. You may need to configure protocols manually."
34+
fi
3135
else
32-
echo "Warning: $RC_DIR not found. You may need to configure RC-6 manually."
36+
echo "Warning: no /dev/lirc* device found."
37+
echo " If your device uses evdev (e.g. Squeezebox Touch), configure it via:"
38+
echo " echo 'INFRAFID_ARGS=\"--evdev /dev/input/event1\"' > /etc/default/infrafid"
39+
echo " Then: systemctl restart infrafid"
3340
fi
3441

3542
# Build

0 commit comments

Comments
 (0)