mirror of
https://github.com/archr-linux/Arch-R.git
synced 2026-03-31 14:41:55 -07:00
lirc: simplify scripts
This commit is contained in:
@@ -17,52 +17,45 @@
|
||||
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
|
||||
################################################################################
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user