#!/usr/bin/env bash

# Read in language
source ${BBROOTDIR}/lang/${BBLANG}/check_path.lang

# Read in vars
source ${BBROOTDIR}/misc/variables.idx

# Some variables
BBBURNING="${BB_CDIMAGECMD} ${BB_CDBURNCMD} ${BB_ISOCMD} ${BB_DVDBURNCMD}"
BBRIPPERS="${BB_CDAUDIORIP} ${BB_READCD}"
BBXCODERS="${BB_MP3ENC} ${BB_OGGENC} ${BB_OGGDEC} ${BB_FLACCMD}"
BBMISC="cut ${BB_EJECT} ${BB_NORMCMD} ${BB_MP3DEC} sed tr sudo"
bb_found_all_apps=0

# Function that check the paths of applications 
# used for BashBurn.
check_path()
{
	for program in $*; do
		if which ${program} &> /dev/null; then
			echo -e "\t ${program} ${BBSUBCOLOR} $bb_cp_1 ${BBCOLOROFF} $bb_cp_2 `which ${program}`"
			(( bb_found_all_apps += 1 )) # Add a one for each app found
		else
			echo -e "\t ${program} ${BBTABLECOLOR} $bb_cp_3 ${BBCOLOROFF} $bb_cp_4"
		fi
	done
	return
}

#####PROGRAM START#####

while true; do
# <colors>
#source "$BBROOTDIR"/misc/colors.idx
# </colors>
echo -e "${BBTABLECOLOR}${BBSUBCOLOR}$bb_cp_5"
echo -e "${BBTABLECOLOR}|>${BBMAINCOLOR}$bb_cp_6${BBCOLOROFF}"
check_path ${BBBURNING}
echo -e "${BBTABLECOLOR}|>${BBMAINCOLOR}$bb_cp_7${BBCOLOROFF}"
check_path ${BBRIPPERS}
echo -e "${BBTABLECOLOR}|>${BBMAINCOLOR}$bb_cp_8${BBCOLOROFF}"
check_path ${BBXCODERS}
echo -e "${BBTABLECOLOR}|>${BBMAINCOLOR}$bb_cp_9${BBCOLOROFF}"
check_path ${BBMISC}
echo

# Only output this if some apps were not found. We don't want to scare people unless necessary :-)
if [ $bb_found_all_apps != 17 ]; then
	echo $bb_cp_10
	echo $bb_cp_11
fi

echo
echo $bb_cp_12
read temp
break

done

