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

# at time of compile gnome-shell v=45.2 which affects my decisions to delete lots of gnome v < 45

export CFLAGS="-mtune=generic -Os -pipe"
export CXX="-mtune=generic -Os -pipe -fno-exceptions -fno-rtti" 

P=Skeuos
P1=skeuos-gtk-themes
P2=skeuos-gnome-themes
V=20220629
SRC=skeuos-gtk-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc  "
for Z in $LIST
    do 
    su -c "tce-load -i $Z" $USER
done

cd /tmp
su -c "/usr/local/bin/wget -nc --no-check-certificate \
https://github.com/daniruiz/skeuos-gtk/archive/refs/tags/20220629.tar.gz " $USER 

tar xvf 20220629.tar.gz
cd $SRC
chmod 755 Makefile
sed 's|usr|usr/local|' -i Makefile
make install DESTDIR=/tmp/$P2 # no strip
cd /tmp

# delete missing desktop
rm -rf $P2/usr/local/share/themes/*XFWM*
# the bulk of themes are Gnomes move the non-gnome to new TCE
DIR=/tmp/$P1/usr/local/share/themes
mkdir -p $DIR
cd $P2/usr/local/share/themes
LIST="$P-Black-Light $P-Blue-Dark $P-Blue-Light $P-Brown-Dark $P-Brown-Light $P-Cyan-Dark $P-Cyan-Light \
$P-Green-Dark $P-Green-Light $P-Grey-Dark $P-Grey-Light $P-Magenta-Dark $P-Magenta-Light $P-Orange-Dark $P-Orange-Light \
$P-Red-Dark $P-Red-Light $P-Teal-Dark $P-Teal-Light $P-Violet-Dark $P-Violet-Light $P-White-Dark $P-Yellow-Dark $P-Yellow-Light"
for Z in $LIST
do
   rm -rf $Z/cinnamon $Z/metacity-1  
mv $Z $DIR
done
cd /tmp


mkdir -p $P1/usr/local/share/doc/$P1
echo 'GPL v 3' > $P1/usr/local/share/doc/$P1/COPYING

# all gnome themes are gnome version 36 38 40 41 42  SO NOT SUBMITTED

# submitqc finds file perm issues fix
find $P1 -type d     | xargs chmod 755
find $P1 -name *.png | xargs chmod 644 
find $P1 -name *.css | xargs chmod 644
find $P1 -name *.svg | xargs chmod 644
find $P1 -name *rc   | xargs chmod 644
find $P1 -name *.theme | xargs chmod 644

# create TCZ
###########
LIST="$P1  "
for Z in $LIST
do
	mksquashfs $Z $Z.tcz
	md5sum $Z.tcz > $Z.tcz.md5.txt
	cd $Z
	find . -not -type d | cut -c 2- | sort > /tmp/$Z.tcz.list
	cd /tmp
done

ls -hal

echo "Title:          skeuos-gtk-themes.tcz
Description:    skeumorphic gtk themes as below
Version:        20220629
Author:         Daniel Ruiz de Alegría
Original-site:  https://github.com/daniruiz/skeuos-gtk
Copying-policy: GPL v3
Size:           3.2M          
Extension_by:   aus9 @linuxquestions.org  
Tags:           gtk2 gtk3 gtk4 theme
Comments:       Features: bevels (rounded corners)
                - drop-shadows, and gradients
                Many colour-{light|dark} themes
                Bulk of cursor themes are Adwaita

                Its safe to ignore warning
Unable to locate theme engine in module_path: "adwaita"

                Highly recommend you use lxappearance to set theme
                Otherwise edit as needed,
                $HOME/.gtkrc-2.0
                $HOME/.config/gtk-3.0/settings.ini
                untested gtk4
                                              
Change-log:     2024/12/01 any arch
Current:        2024/12/01  " > $P1.tcz.info

echo 'librsvg.tcz
adwaita-icon-theme.tcz  ' > $P1.tcz.dep

submitqc --libs 
rm -rf *.zsync