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..95948f7 --- /dev/null +++ b/packages/graphics/bcm2835-driver/files/kodi-splash.sh @@ -0,0 +1,52 @@ +#!/bin/sh + +URL="http://milhouse.openelec.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 + ${PLAYER} ${SPLASH} + fi +fi + +exit 0 diff --git a/packages/graphics/bcm2835-driver/package.mk b/packages/graphics/bcm2835-driver/package.mk index ce11128..6256b9b 100644 --- a/packages/graphics/bcm2835-driver/package.mk +++ b/packages/graphics/bcm2835-driver/package.mk @@ -82,6 +82,9 @@ 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 $FLOAT/opt/vc/bin/hello_video.bin ] && cp -PRv $FLOAT/opt/vc/bin/hello_video.bin $INSTALL/usr/bin + cp -PRv $ROOT/../keep/bin/hello_video.bin $INSTALL/usr/bin + cp -PRv $PKG_DIR/files/kodi-splash.sh $INSTALL/usr/bin && chmod +x $INSTALL/usr/bin/kodi-splash.sh mkdir -p $INSTALL/opt/vc ln -sf /usr/lib $INSTALL/opt/vc/lib @@ -90,4 +91,5 @@ makeinstall_target() { post_install() { enable_service fbset.service 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..56e98d8 --- /dev/null +++ b/packages/graphics/bcm2835-driver/system.d/kodi-splash.service @@ -0,0 +1,13 @@ +[Unit] +Description=Kodi splash animation +ConditionPathExists=!/storage/.config/splash.disable +Before=kodi.service +After=kodi-autostart.service +Requires=graphical.target + +[Service] +Type=simple +ExecStart=/usr/bin/kodi-splash.sh + +[Install] +WantedBy=kodi.service