#!/bin/bash

sleep 5

PFAD=/storage/UBUNTU/vdr

cd /storage/UBUNTU/vdr
NEXT=vdr;

while true;
do
   case "$NEXT" in
  "xbmc")
	systemctl unmask kodi
	systemctl start kodi
	sleep 5
	while ps axg | grep -vw grep | grep -w kodi.bin > /dev/null; do sleep 2; done

       systemctl stop kodi
       systemctl mask kodi
       $PFAD/svdrpsend.sh REMO on 
       $PFAD/svdrpsend.sh PLUG softhdodroid ATTA -a hw:CARD=AMLAUGESOUND,DEV=2
       $PFAD/svdrpsend.sh chan + 
       $PFAD/svdrpsend.sh chan - 
       NEXT=vdr;
       ;;
   "vdr")
       ./looper
       $PFAD/svdrpsend.sh PLUG softhdodroid DETA
       $PFAD/svdrpsend.sh REMO off
       NEXT=xbmc;
       ;;
    esac
done

