From 4530e2171c62992dca7a56b775c5fd18e8980ea6 Mon Sep 17 00:00:00 2001 From: MilhouseVH Date: Sat, 11 Feb 2017 21:27:40 +0000 Subject: [PATCH] kodi: Add experimental Kodi splash video --- .../graphics/bcm2835-driver/files/kodi-splash.sh | 53 ++++++++++++++++++++++ packages/graphics/bcm2835-driver/package.mk | 5 ++ .../bcm2835-driver/system.d/kodi-splash.service | 12 +++++ 3 files changed, 70 insertions(+) create mode 100755 packages/graphics/bcm2835-driver/files/kodi-splash.sh create mode 100644 packages/graphics/bcm2835-driver/system.d/kodi-splash.service diff --git a/packages/graphics/bcm2835-driver/files/kodi-splash.sh b/packages/graphics/bcm2835-driver/files/kodi-splash.sh new file mode 100755 index 0000000..63a7290 --- /dev/null +++ b/packages/graphics/bcm2835-driver/files/kodi-splash.sh @@ -0,0 +1,53 @@ +#!/bin/sh + +URL="http://milhouse.libreelec.tv/other/splash.h264" +PLAYER="/usr/bin/hello_video.bin" +SPLASH="/storage/.cache/splash.h264" + +kodinotify() +{ + sleep 30 + /usr/bin/kodi-send -a "Notification(\"Splash video download\", \"$1\", 5000)" &>/dev/null +} + +waitfornetwork() +{ + local lcount=60 rcount=30 + + # Wait for local network + while [ ${lcount} -gt 0 -a -z "$(connmanctl state 2>/dev/null | grep State | grep -E "ready|online")" ]; do sleep 1; lcount=$((lcount - 1)); done + [ ${lcount} -ne 0 ] || return 1 + + # Wait for internet (remote) network + while [ ${rcount} -gt 0 -a -z "$(ping -qc1 -w1 8.8.8.8 2>/dev/null | grep "1 packets received")" ]; do sleep 1; rcount=$((rcount - 1)); done + [ ${rcount} -ne 0 ] || return 1 + + return 0 +} + +downloadvideo() +{ + local MD5_REMOTE MD5_LOCAL + waitfornetwork || return 1 + wget -q ${URL} -O ${SPLASH}.tmp 2>/dev/null || return 1 + MD5_REMOTE="$(wget -q ${URL}.md5 -O - | awk '{print $1}')" + MD5_LOCAL="$(md5sum ${SPLASH}.tmp | awk '{print $1}')" + if [ -n "${MD5_REMOTE}" -a "${MD5_REMOTE}" == "${MD5_LOCAL}" ]; then + mv ${SPLASH}.tmp ${SPLASH} 2>/dev/null + return 0 + else + rm -f ${SPLASH}.tmp + return 1 + fi +} + +if [ -x ${PLAYER} ]; then + if [ ! -f ${SPLASH} ]; then + downloadvideo && kodinotify "Successful" || kodinotify "Failed" + else + (sleep 1 && /sbin/fbset -g 1 1 1 1 32) & + ${PLAYER} ${SPLASH} + fi +fi + +exit 0 diff --git a/packages/graphics/bcm2835-driver/package.mk b/packages/graphics/bcm2835-driver/package.mk index b6a1fb8..dfb7683 100644 --- a/packages/graphics/bcm2835-driver/package.mk +++ b/packages/graphics/bcm2835-driver/package.mk @@ -64,6 +64,10 @@ makeinstall_target() { cp -PRv $FLOAT/opt/vc/bin/vcgencmd $INSTALL/usr/bin cp -PRv $FLOAT/opt/vc/bin/tvservice $INSTALL/usr/bin cp -PRv $FLOAT/opt/vc/bin/edidparser $INSTALL/usr/bin + [ -f ${MYBUILDROOT}/keep/bin/hello_video.bin ] && cp -PRv ${MYBUILDROOT}/keep/bin/hello_video.bin $INSTALL/usr/bin + for f in $PKG_DIR/files/*.sh; do + cp -PRv $f $INSTALL/usr/bin && chmod +x $INSTALL/usr/bin/$(basename $f) + done mkdir -p $INSTALL/opt/vc ln -sf /usr/lib $INSTALL/opt/vc/lib @@ -71,4 +75,5 @@ makeinstall_target() { post_install() { enable_service unbind-console.service + enable_service kodi-splash.service } diff --git a/packages/graphics/bcm2835-driver/system.d/kodi-splash.service b/packages/graphics/bcm2835-driver/system.d/kodi-splash.service new file mode 100644 index 0000000..2a56d77 --- /dev/null +++ b/packages/graphics/bcm2835-driver/system.d/kodi-splash.service @@ -0,0 +1,12 @@ +[Unit] +Description=Kodi splash animation +ConditionPathExists=!/storage/.config/splash.disable +Before=kodi-autostart.service +Requires=graphical.target + +[Service] +Type=simple +ExecStart=/usr/bin/kodi-splash.sh + +[Install] +WantedBy=kodi.service -- 2.7.4