#!/bin/bash

COMMON_SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

package_manager="none"

# arg($1) = Program's name
install_prog()  
{
	color_start "themeInstall"
	echo "--> $1"
	echo " |--> Will Be Installed"
	echo ""
	color_stop
	${pckgmngr_list[$OS_NO]} $1	
}

# arg($1) = Program's name
skip_prog()
{
	color_start "themeSkip"
	echo "--> $1"
	echo " |--> Was found and will not be installed"
	echo ""
	color_stop
}

install_from_list() 
{
	theList=("$@")
	for i in "${!theList[@]}";
	do	
		currentProg=${theList[$i]}

		if [ $( check_installed $currentProg ) -eq 0 ]
		then
			install_prog $currentProg
		else
			skip_prog $currentProg
		fi
	done
}

install_from_scritp() 
{
	theList=("$@")
	for i in "${!theList[@]}";
	do	
		currentProg=${theList[$i]}
		install_$currentProg
	done
}

install_start()
{
	graphics_indication "Common installations these programs are OS independent from"
	install_from_list "${common_programs_list[@]}"
	graphics_indication "Istallation will begin for $OS"

	case $OS in
	  debian)
		graphics_indication "Default installation will begin for $OS"
		install_from_list "${default_installs_debian[@]}"
		graphics_indication "Custom installations will begin for $OS"
		install_from_scritp "${custom_installs_debian[@]}"
		;;

	  arch)
		graphics_indication "Default installation will begin for $OS"
		install_from_list "${default_installs_arch[@]}"
		graphics_indication "Custom installations will begin for $OS"
		install_from_scritp "${custom_installs_arch[@]}"
		;;

	  rasberry)
		graphics_indication "Default installation will begin for $OS"
		install_from_list "${default_installs_raspberry[@]}"
		graphics_indication "Custom installations will begin for $OS"
		install_from_scritp "${custom_installs_raspberry[@]}"
		;;

	  *)
		echo "Invalid os for installation"
		exit_abord
		;;
	esac
}
