openivi-html5.sh: Configure HTML5 application 95/7295/4
authorLeon Anavi <leon.anavi@konsulko.com>
Thu, 24 Nov 2016 12:05:52 +0000 (14:05 +0200)
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>
Fri, 25 Nov 2016 15:31:15 +0000 (15:31 +0000)
Select HTML5 application that should be loaded on
boot (such as a homescreen) through the systemd
service of openivi-html5. Following the
recommendations of XDG base dir specification,
the configuration file should be located at
$XDG_CONFIG_DIRS/openivi-html5/openivi-html5.ini
and it should contain value for homescreen with
path to HTML file. If the configuration file does
not exist or if the HTML does not exist then
openivi-html5 will load the following sample
HTML5 by default:
/usr/share/openivi/example/cluster/index.html

Bug-AGL: SPEC-332

Change-Id: I496b0ccbcb09f8964042f9d07abad2d552376b80
Signed-off-by: Leon Anavi <leon.anavi@konsulko.com>
recipes-openivi/openivi-html5/openivi-html5/openivi-html5.sh

index ed8a561..190ab65 100644 (file)
@@ -1,9 +1,25 @@
 #!/bin/sh
 
+if test -z "$XDG_CONFIG_DIRS"; then
+    export XDG_CONFIG_DIRS=/etc/xdg/
+fi
+
 if test -z "$XDG_RUNTIME_DIR"; then
     export XDG_RUNTIME_DIR=/run/user/$UID
     mkdir --parents $XDG_RUNTIME_DIR
     chmod 0700 $XDG_RUNTIME_DIR
 fi
 
-/usr/bin/openivi-html5 -f -u /usr/share/openivi/example/cluster/index.html
+# Default homescreen
+HOMESCREEN=/usr/share/openivi/example/cluster/index.html
+
+# Read configuration
+HOMESCREEN_CONFIG=$XDG_CONFIG_DIRS/openivi-html5/openivi-html5.ini
+if [ -e "$HOMESCREEN_CONFIG" ] ; then
+    HTML=`sed -n '/^homescreen=\(.*\)$/s//\1/p' <  $HOMESCREEN_CONFIG`
+    if [ -e "$HTML" ] ; then
+        HOMESCREEN=$HTML
+    fi
+fi
+
+/usr/bin/openivi-html5 -f -u $HOMESCREEN