#!/bin/sh
# test we are root
if [ "$(id -u)" != "0" ]; then
   echo "run as root now exitting"
   exit 1
fi

PRAW=faenza-icon-theme
V=1.3.4
SRC=faenza-icon-theme_1.3
USER=`cat /etc/sysconfig/tcuser`
LIST="submitqc "
for Z in $LIST 
    do 
    su -c "tce-load -i $Z" $USER
done

D1=https://dl.opendesktop.org/api/files/downloadfile/id/1521093265/s
D2=bee540fecebd1142302fe956afde48dd/t/1525657985/u/240113
cd /tmp
su -c "/usr/local/bin/wget -nc --no-check-certificate \
$D1/$D2/$PRAW-$V.tar.gz " $USER
tar xvf $PRAW*gz

# unpacks as faenza-icon-theme_1.3
# that dir has icon tarballs that:
# testing shows the Ambiance pack too close to adwaita
# Radiance too close to Darkest
# Dark not as useful as Darkest
# Darker similar to Darkest
# not sure what emesene does
# so our targets are Darkest and basic

P=Faenza-icon-theme
PD=Faenza-Darkest-icon-theme
cd $SRC
tar xvf Faenza-Darkest*gz
tar xvf Faenza.*gz
cd /tmp

########
# Faenza
########
mkdir -p $P/usr/local/share/icons
mv $SRC/Faenza $P/usr/local/share/icons/
mkdir -p $P/usr/local/share/doc/$P
# authors found https://github.com/shlinux/faenza-icon-theme/blob/master/AUTHORS 
# submitter at xfce site has improved it
echo 'https://github.com/shlinux/faenza-icon-theme/blob/master/LICENSE' \
> $P/usr/local/share/doc/$P/LICENSE

tce.install
#############
mkdir -p $P/usr/local/tce.installed

cat >> $P/usr/local/tce.installed/$P <<'EOF'
#!/bin/sh
gtk-update-icon-cache /usr/local/share/icons/Faenza
EOF
chown -R root:staff $P/usr/local/tce.installed
chmod -R 755 $P/usr/local/tce.installed

########
# Faenza-Darkest
########
mkdir -p $PD/usr/local/share/icons
mv $SRC/Faenza-Darkest $PD/usr/local/share/icons/
mkdir -p $PD/usr/local/share/doc/$PD
# authors found https://github.com/shlinux/faenza-icon-theme/blob/master/AUTHORS 
# submitter at xfce site has improved it
echo 'https://github.com/shlinux/faenza-icon-theme/blob/master/LICENSE' \
> $PD/usr/local/share/doc/$PD/LICENSE

tce.install
#############
mkdir -p $PD/usr/local/tce.installed

cat >> $PD/usr/local/tce.installed/$PD <<'EOF'
#!/bin/sh
gtk-update-icon-cache /usr/local/share/icons/Faenza-Darkest
EOF
chown -R root:staff $PD/usr/local/tce.installed
chmod -R 755 $PD/usr/local/tce.installed

# TCZ them
#######
LIST="$P $PD"
for Z in $LIST
do
	mksquashfs $Z $Z.tcz
	md5sum $Z.tcz > $Z.tcz.md5.txt
	cd $Z
	find usr -not -type d > /tmp/$Z.tcz.list
        sed 's|usr|/usr|g' -i /tmp/$Z.tcz.list
	cd /tmp
done

echo 'gtk3.tcz' > $P.tcz.dep
echo 'gtk3.tcz' > $PD.tcz.dep

echo 'Title:          Faenza-icon-theme.tcz  
Description:    icon theme 
Version:        1.3.4
Author:         Adolfo Silerio based on
                Matthieu James with credits to
                Holger Seelig and clemyeats
Original-site:  https://www.xfce-look.org/p/1212066/
Copying-policy: GPL v3
Size:		
Extension_by:   aus9 at gmx dot com
Tags:           xfce gtk3 theme gnome icon
Comments:       gtk3 icon theme 
                
                XFCE settings -> Appearance -> Icons 
                May work on other WMs too

                Compiled for 64 9.x
Change-log:     2018/05/23  First version 
Current:        2018/05/23 ' > $P.tcz.info

echo 'Title:          Faenza-Darkest-icon-theme.tcz  
Description:    icon dark theme 
Version:        1.3.4
Author:         Adolfo Silerio based on
                Matthieu James with credits to
                Holger Seelig and clemyeats
Original-site:  https://www.xfce-look.org/p/1212066/
Copying-policy: GPL v3
Size:		
Extension_by:   aus9 at gmx dot com
Tags:           xfce gtk3 theme gnome icon
Comments:       gtk3 icon dark theme 
                
                XFCE settings -> Appearance -> Icons 
                May work on other WMs too

                Compiled for 64 9.x
Change-log:     2018/05/23  First version 
Current:        2018/05/23 ' > $PD.tcz.info

submitqc --libs
