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

export CFLAGS="-mtune=generic -Os -pipe"  
export CXXFLAGS="-mtune=generic -Os -pipe -fno-exceptions "

P=lxappearance
V=0.6.4
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc intltool gtk3-dev lxde-icon-theme automake libXcursor-dev 
libXcomposite-dev libXinerama-dev libepoxy-dev   "
for Z in $LIST 
    do 
    su -c "tce-load -i $Z" $USER
done

cd /tmp
/usr/local/bin/wget -nc --no-check-certificate \
https://github.com/lxde/$P/archive/refs/tags/$V.tar.gz
tar xvf $V*gz
cd $SRC
./autogen.sh
./autogen.sh autoupdate
./configure --prefix=/usr/local --enable-gtk3 --disable-dbus --enable-debug=no
# Enable debug....................: no
# Enable Dbus support.............: no
# Prefix..........................: /usr/local
make -j6  # seconds
make install-strip DESTDIR=/tmp/$P
cd /tmp

# nothing in repo depends on existing bmarkus dev so delete it
rm -rf $P/usr/local/include $P/usr/local/lib

# doc
#####
mkdir -p $P-doc/usr/local/share/
mv $P/usr/local/share/man $P-doc/usr/local/share/

# locale
#########
mkdir -p $P-locale/usr/local/share
mv $P/usr/local/share/locale $P-locale/usr/local/share

# main
######
mkdir -p $P/usr/local/share/doc/$P
echo 'GPL v 2' > $P/usr/local/share/doc/$P/COPYING

# desktop stuff
################
mkdir -p $P/usr/local/share/pixmaps
cp /usr/local/share/icons/nuoveXT2/48x48/apps/preferences-desktop-theme.png $P/usr/local/share/pixmaps/lxappearance.png
DESK=$P/usr/local/share/applications/$P.desktop
sed 's|Name=Customize Look and Feel|Name=lxappearance|' -i $DESK
# locales left untouched ^^ 
sed 's|preferences-desktop-theme|lxappearance|' -i $DESK
sed '190,191d' -i $DESK # removes not show and startup notify lines
sed 's|X-LXDE-Settings;|X-Applications|' -i $DESK # add more menu items
echo 'X-FullPathIcon=/usr/local/share/pixmaps/lxappearance.png' >> $DESK

# TCZ them
#######
LIST="$P $P-doc $P-locale "
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:          lxappearance-doc.tcz
Description:    man page
Version:        0.6.4
Author:         Original Hong Jen Yee, Ying-Chun Liu & Martin Bagge
                New Martin Bagge
Original-site:  https://github.com/lxde/lxappearance
Copying-policy: GPL v 2
Size:           4.0K
Extension_by:   aus9 @linuxquestions.org
Tags:           gtk2 gtk3 gtk4 theme
Comments:       -
                
Change-log:     2014/01/19 v 0.5.5 on 5x (bmarkus)
                2024/12/03 v 0.6.3 on 15x (aus9)
Current:        2025/12/03 v 0.6.4 on 16x New upstream site-exe=lxwl not needed '  > $P-doc.tcz.info
echo 'man-db.tcz' >  $P-doc.tcz.dep

echo 'Title:          lxappearance-locale.tcz
Description:    language files
Version:        0.6.4
Author:         Original Hong Jen Yee, Ying-Chun Liu & Martin Bagge
                New Martin Bagge
Original-site:  https://github.com/lxde/lxappearance
Copying-policy: GPL v 2
Size:           144K
Extension_by:   aus9 @linuxquestions.org
Tags:           gtk2 gtk3 gtk4 theme
Comments:       untested by me
                
Change-log:     2014/01/19 v 0.5.5 on 5x (bmarkus)
                2024/12/03 v 0.6.3 on 15x (aus9)
Current:        2025/12/03 v 0.6.4 on 16x New upstream site-exe=lxwl not needed '  > $P-locale.tcz.info
echo 'lxappearance.tcz ' > $P-locale.tcz.dep

echo 'Title:          lxappearance.tcz
Description:    GUI gtk theme, icon & fonts switcher
Version:        0.6.4
Author:         Original Hong Jen Yee, Ying-Chun Liu & Martin Bagge
                New Martin Bagge
Original-site:  https://github.com/lxde/lxappearance
Copying-policy: GPL v 2
Size:           40K
Extension_by:   aus9 @linuxquestions.org
Tags:           gtk2 gtk3 gtk4 theme icon fonts
Comments:       GUI way of changing values for 
                $HOME/.gtkrc-2.0
                $HOME/.config/gtk-3.0/settings.ini
                gtk4 not tested may need adwaita-icon-theme 
                ------according to arch wiki

                Optional TCEs 
                skeuos-* for colours for TAB=widget
                adwaita* humanity* lxde* for TAB=icon
                adwaita* xcursors* oxy-neon* for TAB=cursors                 
                
Change-log:     2014/01/19 v 0.5.5 on 5x (bmarkus)
                2024/12/03 v 0.6.3 on 15x (aus9)
Current:        2025/12/03 v 0.6.4 on 16x New upstream site-exe=lxwl not needed '  > $P.tcz.info
readelf -d $P/usr/local/bin/* | grep 'NEEDED'
#libgtk-3.so.0]#libgdk-3.so.0]gtk3
#libpangocairo-1.0.so.0]#libpango-1.0.so.0]pango gtk3
#libharfbuzz.so.0]harfbuzz
#libatk-1.0.so.0]at-spi2-core gtk3
#libcairo-gobject.so.2]libcairo.so.2]cairo pango gtk3
#libgdk_pixbuf-2.0.so.0]gdk-pixbuf2 gtk3
#libgio-2.0.so.0 libgobject-2.0.so.0 libgthread-2.0.so.0 libglib-2.0.so.0libgmodule-2.0.so.0 glib2 cairo pango gtk3
#libX11.so.6]libX11 cairo pango gtk3

# when I load lxapperance with hicolor error is
# (lxappearance:4369): Gtk-WARNING **: 13:13:55.999: Could not find the icon 'user-home-ltr'. The 'hicolor' theme
# was not found either, perhaps you need to install it.

echo 'gtk3.tcz
hicolor-icon-theme.tcz' > $P.tcz.dep

submitqc --libs
rm -rf *.zsync

