#!/bin/sh

# ArchLinux installers
#
# Authors:
#  Brzulovic Misel <brzulovic@gmail.com>
# License: GPLv2 or later

init()
{
	
	echo ""
	echo ""
	echo "Please Enter which window manager you want to install ?"
	echo "----------------"
	echo "   1- configuration"
	echo "   2- materiel"
	echo "   3- window managers"
	echo "   4- apps"
	echo "   0- exit"
	echo "----------------"
	echo -n "Enter your choice and press [ENTER]: "
	read choice

		
	if [ $choice -eq 1 ]; then
		echo " opening configuration"
		sh configuration.sh
	
	elif [ $choice -eq 2 ]; then
		echo " opening materiel"
		sh materiel.sh
		
	
	elif [ $choice -eq 3 ]; then
		echo " opening window managers"
		sh wm.sh
		
	elif [ $choice -eq 4 ]; then
		echo " opening apps"
		sh apps.sh
		
	elif [ $choice -eq 0 ]; then
		echo " exiting ..."
		echo ""
		exit 1
		
	else
		echo " Nothing done"
		echo ""
		echo "Retry again..."
		init
		#exit 1
	fi

	echo ""
	sh install.sh
}



init_dialog()
{


	I1(){ false;}
	I2(){ false;}
	I3(){ false;}
	I4(){ false;}
	I5(){ false;}
	I6(){ false;}
	I7(){ false;}
	I8(){ false;}
	I9(){ false;}
	I0(){ false;}
	IA(){ false;}
	IM(){ false;}

	{
	eval "$(
	dialog --output-fd 3 \
	--radiolist 'Please Enter which window manager you want to install ?' 0 0 0 \
	I1 Configuration	 off \
	I2 Materiel			 off \
	I3 Window_managers	 off \
	I4 Apps				 off \
	I5 AllInOne			 on \
	I0 Exit 			 off \
	3>&1 >&4 4>&- |
	sed 's/$/(){ true;}/')"
	} 4>&1
	
	if I0; then
		echo " exiting ...\n"
		exit 1
	fi
	
	if I1; then
		sh configuration.sh
	fi
	
	if I2; then
		sh materiel.sh
	fi
	if I3; then
		sh wm.sh
	fi
	if I4; then
		sh apps.sh
	fi
	if I5; then
		sh allinone.sh
	fi
	
	sh install.sh
}


#init
init_dialog
