#!/bin/bash
#
#  Masalla Icon Theme
#
#  Copyright 2018 hayder majid <hayder@riseup.net>
#  
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 3 of the License, or
#  (at your option) any later version.
#  
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#  
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, you can download it from here:
#  https://www.gnu.org/licenses/gpl-3.0.html
#
# installing script for masalla icon themes 
# Written by Hayder Majid (Hayder Ctee) <hayder@riseup.net> (thanks to Tiheum <matthieu.james@gmail.com> for writting his script :-) )
echo ""
cat Banner1.txt
sleep 1.5
cat Banner2.txt
sleep 1.5
cat Banner3.txt
sleep 1.5
ROOT_UID=0
if [ "$UID" -ne "$ROOT_UID" ]
then
	echo "Masalla Colors will be installing in $HOME/.icons. To make them available for all users, run this script as root."
    echo "make sure you have (masalla icon theme 1.5) installed on your system befor you continue"
else
	echo "Masalla Colors will be installing in /usr/share/icons and will be available for all users."
    echo "make sure you have (masalla icon theme 1.5) installed on your system befor you continue"
fi
read -p "Do you want to continue ? [Y]es, [N]o : " response
case $response in
	[Yy]* ) ;;
    [Nn]* ) exit 99;;
    * ) echo "Wrong value: installaton aborted."; exit 1;;
esac


if [ -d $HOME/.icons/masalla ]
then
	echo
	read -p "An existing installation have been detected in $HOME/.icons. Remove it previously ? [Y]es, [N]o :" response
	case $response in
		[Yy]* ) ./CLEAN ;;
	    * ) ;;
	esac
fi

if [ "$UID" -eq "$ROOT_UID" ]
then
	sudo ./CLEAN
	cp -R ./masalla* /usr/share/icons/
        sudo gtk-update-icon-cache  /usr/share/icons/*
	install_dir=/usr/share/icons/
else
	./CLEAN
	cp -R ./masalla* $HOME/.icons/
        sudo gtk-update-icon-cache  $HOME/.icons/*
	install_dir=$HOME/.icons/
fi
echo ""
echo "Your new Masalla Icon Theme installed in $install_dir"
echo "To find the latest update, please check the main repository :"
echo " https://notabug.org/masalla-art/masalla-icon-theme"
echo ""
echo "Installation complete. Enjoy !"
exit 0
