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

USER=`cat /etc/sysconfig/tcuser`
LIST="submitqc squashfs-tools  "
for Z in $LIST 
    do 
    su -c "tce-load -i $Z" $USER
done

P=weston.ini
cd /tmp
mkdir -p $P/usr/local/share/weston/files

echo '# see https://www.mankier.com/5/weston.ini
# see https://www.mankier.com/7/weston-drm
# see https://wiki.archlinux.org/title/Weston#Shortcuts
[core]
#modules=screen-share.so
xwayland=true
#shell=desktop
#gbm-format=xrgb2101010
#require-input=true

#[libinput]
#enable-tap=true
#tap-and-drag=true
#tap-and-drag-lock=true
#disable-while-typing=false
#middle-button-emulation=true
#left-handed=true
#rotation=90
#accel-profile=flat
#accel-speed=.9
#natural-scroll=true
#scroll-method=edge
# For button-triggered scrolling:
#scroll-method=button
#scroll-button=BTN_RIGHT

[shell]
# change pathway files where appropiate
background-image=/home/tc/2wallpaper/3d.jpeg
background-color=0xff002244
background-type=tile
clock-format=minutes
panel-color=0xff000000
locking=true
animation=zoom
startup-animation=fade
#binding-modifier=ctrl
num-workspaces=6
#cursor-theme=whiteglass
#cursor-size=24
#animation=fade

[launcher]
icon=/usr/local/share/pixmaps/exittc.png
path=/usr/local/bin/exittc

[launcher]
icon=/usr/local/share/pixmaps/sakura.png
path=/usr/local/bin/sakura

[launcher]
icon=/usr/local/share/pixmaps/apps.png
path=/usr/local/bin/apps

[output]
name=HDMI-A-0
mode=1280x1024

#name=LVDS1
#mode=1680x1050
#transform=90
#icc_profile=/usr/share/color/icc/colord/Bluish.icc

#name=VGA1
#mode=173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync
#transform=flipped

#name=X1
#mode=1024x768@60
#transform=flipped-90

[input-method]
# on screen keyboard input method
path=/usr/local/lib/weston/weston-keyboard

#[touchpad]
#constant_accel_factor = 50
#min_accel_factor = 0.16
#max_accel_factor = 1.0

[keyboard]
keymap_layout=us
numlock-on=true

[xwayland]
path=/usr/local/bin/Xwayland

[screen-share]
command=/usr/local/bin/weston --backend=rdp --shell=fullscreen --no-clients-resize
#start-on-startup=false

[autolaunch]
path=/usr/local/bin/firefox   ' > $P/usr/local/share/weston/files/.weston.ini
       
mkdir -p $P/usr/local/share/doc/$P
echo 'open source' > $P/usr/local/share/doc/$P/COPYING

# tce.installed
#############
mkdir -p $P/usr/local/tce.installed
cat > $P/usr/local/tce.installed/$P << 'EOF'
#/bin/sh
USER=`cat /etc/sysconfig/tcuser`
C=/home/$USER/.config
W=.weston.ini
L=/tmp/tcloop/weston.ini/usr/local/share/weston/files/$W
# assume members have made a mess of their current config. Although this may be the first time they run it,
# force delete existing file and create a fresh one,  with no test of any (good or bad) config

rm -rf $C/$W
cp $L  $C/
chown $USER $C/$W
chmod 644 $C/$W
EOF
chown -R root:staff $P/usr/local/tce.installed
chmod -R 775 $P/usr/local/tce.installed


# 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:          weston.ini.tcz  
Description:    an read-write config for weston 
Version:        3
Author:         aus9 
Original-site:  Cheating off     https://www.mankier.com/5/weston.ini
                and modes mainly https://www.mankier.com/7/weston-drm
Copying-policy: Open source
Size:           4.0K	
Extension_by:   aus9 @linuxquestions.org
Tags:           weston compositor wayland
Comments:       config file will create at   ~/.config/weston.ini
                
                (Upgrade) install script will destroy exiting config file
                so move your current out of ~/.config. This TCE is therefore 
                designed to be run only once, then you make changes to config file
                So do NOT have this in your boot list please.

                There are independent keybindings showing here
                https://wiki.archlinux.org/title/Weston#Shortcuts

                Without xwayland loaded, run $ exitcheck.sh reboot (to reboot) 
                or drop reboot to poweroff. All fltk GUIs work without xwayland
                EXCEPT exittc.
                
                Optional TCEs/commands depend on what you need to config
                TCE=xwayland a dep of this TCE but not yet a dep of weston
                TCE=Xorg-7.7-bin allows $ xrandr -q for output settings
                TCE=colord provides files like Bluish.icc
                TCE=sakura reduces broken pipe errors vs weston-terminal YMMV
                
                No sound is setup so TCEs will vary depending on whether you prefer
                alsa (with optional apulse), pulseaudio/pavucontrol*, pipewire and naturally
                read the relevant info files please

Change-log:     2018/11/27  v 1 
                2024/04/05  v 2
                2024/04/22 fix xwayland & mention sakura terminal for broken pipe issue (had install script)
Current:        2025/03/05 v 3 script - enable xwayland  ' > $P.tcz.info

submitqc --libs
rm -rf *.zsync

