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

# not a compile

P=wofi-dark-theme
V=1.0
USER=`cat /etc/sysconfig/tcuser`
LIST="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://raw.githubusercontent.com/dracula/wofi/refs/heads/master/style.css \
https://raw.githubusercontent.com/dracula/wofi/refs/heads/master/LICENSE     " $USER
tar xvf v$V*gz
chown root:root style.css LICENSE

# create tce
########
mkdir -p $P/usr/local/share/$P
mv style.css $P/usr/local/share/$P

# install script
################
mkdir -p $P/usr/local/tce.installed
cat >> $P/usr/local/tce.installed/$P <<'EOF'
#!/bin/sh
USER=`cat /etc/sysconfig/tcuser`
DIR=/home/$USER/.config/wofi
FILE=/usr/local/share/wofi-dark-theme/style.css
[ -d $DIR ] || mkdir -p $DIR
if [ ! -f $DIR/style.css ] ; then
   cp $FILE $DIR
   chown $USER:staff $DIR/style.css 
   chmod 644 $DIR/style.css 
fi
EOF
chown -R root:staff $P/usr/local/tce.installed
chmod -R 775 $P/usr/local/tce.installed

mkdir -p $P/usr/local/share/doc/$P
mv LICENSE $P/usr/local/share/doc/$P

# TCZ them
#######
LIST="$P  "
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:          wofi-dark-theme.tcz 
Description:    dracula theme for wofi
Version:        git-20241010
Author:         Dracula Theme
Original-site:  https://github.com/dracula/wofi
Copying-policy: accompanied
Size:           4.0K		
Extension_by:   aus9 @linuxquestions.org 
Tags:           wofi wlroots theme
Comments:       Install script creates read-writeable
                $HOME/.config/wofi/style.css
              
Change-log:     2024/10/10 v git-20241010 on 15x
Current:        2024/10/10  ' > $P.tcz.info

echo 'wofi.tcz       ' > $P.tcz.dep

submitqc --libs
rm -rf *.zsync

