#!/bin/bash

dir="$(dirname "$0")"

FAVS="$dir/data/favs.list"

# Install preferred applications using the list of packages 'data/favs.list'
function favs {
	if (eval `resize` && whiptail \
		--title "Preferred Applications" \
		--yesno "Current list of preferred applications to install: \n\n$(cat $FAVS) \n\nProceed with installation?" \
		$LINES $COLUMNS $(( $LINES - 12 )) \
		--scrolltext) then
		show_info 'Installing...'
		show_warning 'Requires root privileges'
		sudo apt install -y --no-install-recommends $(cat $FAVS)
		# Done
		show_success 'Done.'
		# Check
		EXITSTATUS=$1
		if [[ $EXITSTATUS != 0 ]]; then
			# Already installed
			show_success 'Already installed.'
			whiptail --title "Finished" --msgbox "Your preferred applications are installed." 8 78
			main
		else
			whiptail --title "Finished" --msgbox "Installation complete." 8 78
			main
		fi
	else
		main
	fi
}