#!/bin/bash

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

#################################################################################
# INCLUDES									#
#################################################################################
source $INSTALL_CMDS_DIR/dmenu/dmenu.sh
source $INSTALL_CMDS_DIR/fonts/fonts.sh
source $INSTALL_CMDS_DIR/alacritty/alacritty.sh
source $INSTALL_CMDS_DIR/wallpaper/wallpaper.sh
source $INSTALL_CMDS_DIR/picom/picom.sh
source $INSTALL_CMDS_DIR/obsidian/obsidian.sh
source $INSTALL_CMDS_DIR/xmonad/xmonad.sh
source $INSTALL_CMDS_DIR/sddm/sddm.sh
source $INSTALL_CMDS_DIR/fish/fish.sh
source $INSTALL_CMDS_DIR/vim/vim.sh

#################################################################################
# DECLARATIONS									#
#################################################################################
package_manager="none"


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

		if [ $( check_installed $currentProg ) -eq 0 ]
		then
			color_start "themeInstall"
			echo "--> $currentProg"
			echo " |--> Will Be Installed"
			echo "${pckgmngr_list[$OS_NO]} $currentProg"
			${pckgmngr_list[$OS_NO]} $currentProg	
			color_stop

		else
			color_start "themeSkip"
			echo "--> $currentProg"
			echo " |--> Was found and will not be installed"
			echo ""
			color_stop
		fi
	done
}

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

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

	case $OS in
	  debian)
		graphics_indication "Default installation will begin for $OS"
		install_from_repo "${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_repo "${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_repo "${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
}
