diff --git a/packages/sysutils/lirc/scripts/lircd_helper b/packages/sysutils/lirc/scripts/lircd_helper index 8e79b073a9..d36ce21e03 100755 --- a/packages/sysutils/lirc/scripts/lircd_helper +++ b/packages/sysutils/lirc/scripts/lircd_helper @@ -17,52 +17,45 @@ # along with OpenELEC. If not, see . ################################################################################ -ACTION=$(echo "$1") -DEVICE=$(echo "$2" | cut -f1 -d:) -DRIVER=$(echo "$2" | cut -f2 -d:) -CONFIG=$(echo "$2" | cut -f3 -d:) +DEVICE=$(echo "$1" | cut -f1 -d:) +DRIVER=$(echo "$1" | cut -f2 -d:) +CONFIG=$(echo "$1" | cut -f3 -d:) -case "$ACTION" in - add) - if [ "x$DRIVER" = "x" ]; then - exit 1; - fi +if [ "x$DRIVER" = "x" ]; then + exit 1; +fi - mkdir -p '/run/lirc' +mkdir -p '/run/lirc' - if [ ! -e "/run/lirc/lircd-$DEVICE.pid" ]; then +LIRCD="/usr/sbin/lircd" +LIRCD_UINPUT="/usr/sbin/lircd-uinput" +LIRCD_CONFIG="--driver=$DRIVER --device=/dev/$DEVICE" +LIRCD_CONFIG="$LIRCD_CONFIG --output=/run/lirc/lircd-$DEVICE" +LIRCD_CONFIG="$LIRCD_CONFIG --pidfile=/run/lirc/lircd-$DEVICE.pid" +LIRCD_CONFIG="$LIRCD_CONFIG --release=_LIRCUP" - LIRCD="/usr/sbin/lircd" - LIRCD_CONFIG="--driver=$DRIVER --device=/dev/$DEVICE" - LIRCD_CONFIG="$LIRCD_CONFIG --output=/run/lirc/lircd-$DEVICE" - LIRCD_CONFIG="$LIRCD_CONFIG --pidfile=/run/lirc/lircd-$DEVICE.pid" - LIRCD_CONFIG="$LIRCD_CONFIG --release=_LIRCUP" +if [ -e "/storage/.config/lircd.conf" ]; then + LIRCD_CONFIG="$LIRCD_CONFIG /storage/.config/lircd.conf" +elif [ -n "$CONFIG" ]; then + if [ -e "/storage/.config/$CONFIG" ]; then + LIRCD_CONFIG="$LIRCD_CONFIG /storage/.config/$CONFIG" + elif [ -e "/etc/lirc/$CONFIG" ]; then + LIRCD_CONFIG="$LIRCD_CONFIG /etc/lirc/$CONFIG" + else + echo "No device specific $CONFIG file found" + echo "You need to provide your own $CONFIG file" + echo "Place it in /storage/.config/$CONFIG" + exit 0 + fi +else + echo "No lircd.conf file found" + echo "You need to provide your own lircd.conf file" + echo "Place it in /storage/.config/lircd.conf" + exit 0 +fi - if [ -e "/storage/.config/lircd.conf" ]; then - LIRCD_CONFIG="$LIRCD_CONFIG /storage/.config/lircd.conf" - elif [ -n "$CONFIG" ]; then - if [ -e "/storage/.config/$CONFIG" ]; then - LIRCD_CONFIG="$LIRCD_CONFIG /storage/.config/$CONFIG" - elif [ -e "/etc/lirc/$CONFIG" ]; then - LIRCD_CONFIG="$LIRCD_CONFIG /etc/lirc/$CONFIG" - else - exit 0 - fi - else - exit 0 - fi - - exec $LIRCD $LIRCD_CONFIG - fi - ;; - remove) - if [ -e "/run/lirc/lircd-$DEVICE.pid" ]; then - PID=`cat /run/lirc/lircd-$DEVICE.pid` - if [ ! "x$PID" = "x" ]; then - kill $PID - fi - fi - ;; -esac +# lircd daemonizes but lircd-uinput doesn't so we need to fork it to the background +$LIRCD $LIRCD_CONFIG +$LIRCD_UINPUT --release=_LIRCUP /run/lirc/lircd-$DEVICE & exit 0 diff --git a/packages/sysutils/lirc/system.d/lircd-uinput@.service b/packages/sysutils/lirc/system.d/lircd-uinput@.service deleted file mode 100644 index 85ddf3e3bb..0000000000 --- a/packages/sysutils/lirc/system.d/lircd-uinput@.service +++ /dev/null @@ -1,14 +0,0 @@ -[Unit] -Description=lircd-uinput with %I - -ConditionPathExists=/storage/.cache/services/lircd.conf - -[Service] -ExecStart=/usr/sbin/lircd-uinput --release=_LIRCUP /run/lirc/lircd-%I -Slice=system-lircd.slice -Restart=on-failure -RestartSec=2 - -[Install] -WantedBy=multi-user.target - diff --git a/packages/sysutils/lirc/system.d/lircd@.service b/packages/sysutils/lirc/system.d/lircd@.service index 05798e5055..c377ab528a 100644 --- a/packages/sysutils/lirc/system.d/lircd@.service +++ b/packages/sysutils/lirc/system.d/lircd@.service @@ -6,11 +6,11 @@ Requires=lircd-defaults.service ConditionPathExists=/storage/.cache/services/lircd.conf [Service] -Type=oneshot -ExecStart=/usr/lib/libreelec/lircd_helper add %I -ExecStop=/usr/lib/libreelec/lircd_helper remove %I +Type=forking +ExecStart=/usr/lib/libreelec/lircd_helper %I TimeoutStopSec=1 RemainAfterExit=yes [Install] WantedBy=multi-user.target + diff --git a/packages/sysutils/lirc/udev.d/98-lircd.rules b/packages/sysutils/lirc/udev.d/98-lircd.rules index 0bc7714ed7..aca4dce868 100644 --- a/packages/sysutils/lirc/udev.d/98-lircd.rules +++ b/packages/sysutils/lirc/udev.d/98-lircd.rules @@ -67,12 +67,6 @@ ENV{lircd_driver}=="?*", ENV{lircd_conf}=="?*", ACTION=="add", \ TAG+="systemd", ENV{SYSTEMD_WANTS}+="lircd@$name:$env{lircd_driver}:$env{lircd_conf}.service", \ RUN+="lircd_wakeup_enable" -ENV{lircd_driver}=="?*", ENV{lircd_conf}=="?*", ACTION=="add", \ - TAG+="systemd", ENV{SYSTEMD_WANTS}+="lircd-uinput@$name.service" - -ENV{lircd_driver}=="?*", ENV{lircd_conf}=="?*", ACTION=="remove", \ - RUN+="/usr/bin/systemctl stop lircd-uinput@$name.service" - ENV{lircd_driver}=="?*", ENV{lircd_conf}=="?*", ACTION=="remove", \ RUN+="/usr/bin/systemctl stop lircd@$name:$env{lircd_driver}:$env{lircd_conf}.service"