#!/bin/sh
#
# Start linux launcher...
#

case "$1" in
  start)
		printf "Starting launcher: "
		export LC_ALL='zh_CN.utf8'
		export QT_QPA_PLATFORM=wayland

    # music
    /usr/bin/audioservice &

		# bt
		/usr/libexec/bluetooth/bluetoothd --compat &

		#for kmssink
		export QT_GSTREAMER_WINDOW_VIDEOSINK=kmssink

		#for rkisp plugin
		export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/gstreamer-1.0

		#for waylandsink
		#export QT_GSTREAMER_WINDOW_VIDEOSINK=waylandsink

		# weston runtime dir
		mkdir -p /tmp/.xdg &&  chmod 0700 /tmp/.xdg
		export XDG_RUNTIME_DIR=/tmp/.xdg

		# launch weston with custom config file if it exists
		# DM: March 2022 - dont launch weston on roth - use eglfs
		#if [ -e /mnt/appdata/weston.ini ]; then
		#	weston --tty=2 --idle-time=0 --config=/mnt/appdata/weston.ini &
		#else
		#  weston --tty=2 --idle-time=0 &
		#fi

		#sleep 1
		#/usr/local/QLauncher/QLauncher &

		#for Carmachine wayland
		#/usr/bin/Carmachine -platform wayland -plugin EvdevTouch -plugin EvdevKeyboard &

	;;
  stop)
		#killall QLauncher
		#killall CarMachine
		#killall weston
		printf "stop finished"
        ;;
  *)
        echo "Usage: $0 {start|stop}"
        exit 1
        ;;
esac
exit 0