#!/bin/bash

PREFIX="Icons"
LOCAL="/usr/share/icons/Papirus"

echo "Welcome to the Papirus Nord installer!"
echo "For better usage, run this script as a superuser (sudo)!"

echo -n "Have you previously installed the Papirus' Linux Universe version? (Type Y or N) "
read cond

if [[ ( $cond != "Y" ) && ( $cond != "N" ) ]]
then
    echo "Please enter a valid option!"
    exit 0
fi

install() {
if [ $cond = "Y" ]
then
    cp -f papirus-folders1 /usr/bin/papirus-folders
else
    if [ $cond = "N" ]
    then
        cp -f papirus-folders /usr/bin
    fi
fi
}

if [ ! $USER = "root" ]
then
    if [ ! -d /home/$USER/.icons/Papirus ]
    then
        echo "Install first the papirus icon!"
        exit 0
    else
        echo "Papirus icon already installed!"
        LOCAL="/home/$USER/.icons/Papirus"
    fi
else
    if [ ! -d $LOCAL ]
    then
        echo "Install first the papirus icon!"
        exit 0
    else
        if [ ! -f /usr/bin/papirus-folders ]
        then
            echo "Papirus-folders script is not installed!"
            install
            echo "Papirus-folders script installed!"
        else
            echo "Papirus-folder script has already been installed! It will be overwritten!"
            install
            echo "Papirus-folder script updated!"
        fi
    fi
fi

echo "Instaling icons..."
cp -f $PREFIX/64x64/* $LOCAL/64x64/places
cp -f $PREFIX/48x48/* $LOCAL/48x48/places
cp -f $PREFIX/32x32/* $LOCAL/32x32/places
cp -f $PREFIX/24x24/* $LOCAL/24x24/places
cp -f $PREFIX/22x22/* $LOCAL/22x22/places
echo "Icons installed!"
