#!/usr/bin/env /lib/runit/invoke-run
#Copyright: 2026 Lorenzo Puliti <plorenzo@disroot.org>
#License: CC0-1.0

exec 2>&1

sv start dbus ||  exit 170

#otherwise it exits and restarts loop
#TODO need better testing for no sensors detected case
LOGF=/var/log/runit/iio-sensor-proxy/current
if cat "$LOGF" | tail -n3 | grep -q 'No sensors or missing kernel drivers for the sensors. Exiting' ; then
    sv d iio-sensor-proxy
fi

exec ${XCHPST:-} ##bin##
