#! /bin/sh -e

cd /usr/share/themes

if [ ! $2 ]; then
echo "You must give some arguments..."
echo " "
echo "Usage: convertplastic SOURCETHEME TARGETSCHEME"
echo " "
echo "Example #1: convertplastic alpha Nseries"
echo "Example #2: convertplastic beta DigitalLife"
echo " "
echo "List of available (installed) themes:"
cd /usr/share/themes
ls -1 | grep -v Default | grep -v Raleigh | grep -v Emacs | grep -v default | grep -v blackplastictheme-themedir
exit 0
fi

if [ -d $1 ]; then
cd /usr/share/themes/$1
else
echo "Couldn't find source theme '$1', check your input for typos and try again."
echo " "
echo "List of available (installed) themes:"
cd /usr/share/themes
ls -1 | grep -v Default | grep -v Raleigh | grep -v Emacs | grep -v default | grep -v blackplastictheme-themedir
exit 0
fi

if [ ! -d /opt/plastic-schemes/$2 ]; then
echo "Converting..."
mkdir /opt/plastic-schemes/$2
tar chf - * | tar x -C /opt/plastic-schemes/$2
echo "Done!"
exit 0

else

echo "Scheme with name '$2' already exists! Choose another name for the scheme"
echo "List of current Schemes:"
cd /opt/plastic-schemes/
ls -1 | grep -v css-template | grep -v gtk-template
fi

exit 0