In alpine linux i wanna do a more minimal install of xfce via setup-desktop that does not use x11 xorg but uses wayland instead, also i dont wanna install firefox, study below how can i use setup-wayland-base instead with that script i gave you 


#!/bin/sh

usage() {
	cat <<-__EOF__
		usage: setup-wayland-base [-h] [PKG..]

		Set up system to use Wayland

		options:
		 -h  Show this help

		Installs and enables elogind, enables community repository, enable udev
		and install the packages PKG if specified.
	__EOF__
	exit $1
}

while getopts "h" opt; do
	case $opt in
		h) usage 0;;
		'?') usage "1" >&2;;
	esac
done
shift $(($OPTIND - 1))

# For every main/ repo, enable corresponding community/ repo
setup-apkrepos -o

apk add elogind polkit-elogind eudev "$@"

setup-devd udev

for service in elogind polkit; do
	rc-service "$service" start
	rc-update add "$service"
done



and here's the normal x11 script 

#!/bin/sh

usage() {
	cat <<-__EOF__
		usage: setup-xorg-base [-h] [PKG..]

		Set up system to use Xorg

		options:
		 -h  Show this help

		Installs xorg-server, enables community repository, enable udev and
		install the packages PKG if specified.
	__EOF__
	exit $1
}

while getopts "h" opt; do
	case $opt in
		h) usage 0;;
		'?') usage "1" >&2;;
	esac
done
shift $(($OPTIND - 1))

# For every main/ repo, enable corresponding community/ repo
setup-apkrepos -o

apk add xorg-server xf86-input-libinput xinit eudev mesa-dri-gallium "$@"

setup-devd udev

And now here's also the libalpine.sh script

#!/bin/sh

PREFIX=@PREFIX@

PROGRAM=$(basename $0)

: ${ROOT:=/}
[ "${ROOT}" = "${ROOT%/}" ] && ROOT="${ROOT}/"
[ "${ROOT}" = "${ROOT#/}" ] && ROOT="${PWD}/${ROOT}"

# echo if in verbose mode
vecho() {
	if [ -n "$VERBOSE" ]; then
		echo "$@"
	fi
}

# echo unless quiet mode
qecho() {
	if [ -z "$QUIET" ]; then
		echo "$@"
	fi
}

# echo to stderr
eecho() {
	echo "$@" >&2
}

# echo to stderr and exit with error
die() {
	eecho "$@"
	exit 1
}

init_tmpdir() {
	local omask="$(umask)"
	local __tmpd="/tmp/$PROGRAM-${$}-$(date +%s)-$RANDOM"
	umask 077 || die "umask"
	mkdir -p "$__tmpd" || exit 1
	trap "rc=\$?; rm -fr \"$__tmpd\"; exit \$rc" 0
	umask $omask
	eval "$1=\"$__tmpd\""
}

default_read() {
	local n
	read n
	[ -z "$n" ] && n="$2"
	eval "$1=\"$n\""
}


cfg_add() {
	$MOCK lbu_add "$@"
}

# return true if given value is Y, y, Yes, yes YES etc
yesno() {
	case $1 in
	[Yy]|[Yy][Ee][Ss]) return 0;;
	esac
	return 1
}

# Detect if we are running Xen
is_xen() {
	test -d /proc/xen
}

# Detect if we are running Xen Dom0
is_xen_dom0() {
	is_xen && \
	grep -q "control_d" /proc/xen/capabilities 2>/dev/null
}

# list of all network interfaces, sorted by ifindex
sorted_ifaces() {
	for i in "$ROOT"/sys/class/net/*; do
		local iface="${i##*/}"
		if [ -e "$i"/ifindex ]; then
			printf "%s\t%s\n" "$(cat $i/ifindex)" "$iface"
		fi
	done | sort -n | awk '{print $2}'
}

# list of available network interfaces that aren't part of any bridge or bond
available_ifaces() {
	local iflist= ifpath= iface=
	if ! [ -d "$ROOT"/sys/class/net ]; then
		ip link | awk -F: '$1 ~ /^[0-9]+$/ {printf "%s",$2}'
		return
	fi
	for iface in $(sorted_ifaces); do
		# skip interfaces that are part of a bond or bridge
		ifpath="$ROOT/sys/class/net/$iface"
		if [ -d "$ifpath"/master/bonding ] || [ -d "$ifpath"/brport ] || [ "$iface" = "lo" ]; then
			continue
		fi
		iflist="${iflist}${iflist:+ }$iface"
	done
	echo $iflist
}

# from OpenBSD installer

# Ask for a password, saving the input in $resp.
#    Display $1 as the prompt.
#    *Don't* allow the '!' options that ask does.
#    *Don't* echo input.
#    *Don't* interpret "\" as escape character.
askpass() {
	printf %s "$1 "
	set -o noglob
	$MOCK stty -echo
	read -r resp
	$MOCK stty echo
	set +o noglob
	echo
}

# Ask for a password twice, saving the input in $_password
askpassword() {
	local _oifs="$IFS"
	IFS=
	while :; do
		askpass "Password for $1 account? (will not echo)"
		_password=$resp

		askpass "Password for $1 account? (again)"
		# N.B.: Need quotes around $resp and $_password to preserve leading
		#       or trailing spaces.
		[ "$resp" = "$_password" ] && break

		echo "Passwords do not match, try again."
	done
	IFS=$_oifs
}

# test the first argument against the remaining ones, return success on a match
isin() {
	local _a="$1" _b
	shift
	for _b; do
		[ "$_a" = "$_b" ] && return 0
	done
	return 1
}

# remove all occurrences of first argument from list formed by
# the remaining arguments
rmel() {
	local _a="$1" _b

	shift
	for _b; do
		[ "$_a" != "$_b" ] && printf %s "$_b "
	done
}

# Issue a read into the global variable $resp.
_ask() {
	local _redo=0

	read resp
	case "$resp" in
	!)	echo "Type 'exit' to return to setup."
		sh
		_redo=1
		;;
	!*)	eval "${resp#?}"
		_redo=1
		;;
	esac
	return $_redo
}

# Ask for user input.
#
#    $1    = the question to ask the user
#    $2    = the default answer
#
# Save the user input (or the default) in $resp.
#
# Allow the user to escape to shells ('!') or execute commands
# ('!foo') before entering the input.
ask() {
	local _question="$1" _default="$2"

	while :; do
		printf %s "$_question "
		[ -z "$_default" ] || printf "[%s] " "$_default"
		_ask && : ${resp:=$_default} && break
	done
}

# Ask for user input until a non-empty reply is entered.
#
#    $1    = the question to ask the user
#    $2    = the default answer
#
# Save the user input (or the default) in $resp.
ask_until() {
	resp=
	while [ -z "$resp" ] ; do
		ask "$1" "$2"
	done
}

# Ask for user for y/n until y, yes, n or no is responded
#
#    $1    = the question to ask the user
#    $2    = the default answer
#
#  Returns true/sucess if y/yes was responded. false othewise
ask_yesno() {
	while true; do
		ask "$1" "$2"
		case "$resp" in
			y|yes|n|no) break;;
		esac
	done
	yesno "$resp"
}

# Ask for the user to select one value from a list, or 'done'.
#
# $1 = name of the list items (disk, cd, etc.)
# $2 = question to ask
# $3 = list of valid choices
# $4 = default choice, if it is not specified use the first item in $3
#
# N.B.! $3 and $4 will be "expanded" using eval, so be sure to escape them
#       if they contain spooky stuff
#
# At exit $resp holds selected item, or 'done'
ask_which() {
	local _name="$1" _query="$2" _list="$3" _def="$4" _dynlist _dyndef

	while :; do
		# Put both lines in ask prompt, rather than use a
		# separate 'echo' to ensure the entire question is
		# re-ask'ed after a '!' or '!foo' shell escape.
		eval "_dynlist=\"$_list\""
		eval "_dyndef=\"$_def\""

		# Clean away whitespace and determine the default
		set -o noglob
		set -- $_dyndef; _dyndef="$1"
		set -- $_dynlist; _dynlist="$*"
		set +o noglob
		[ $# -lt 1 ] && resp=done && return

		: ${_dyndef:=$1}
		echo "Available ${_name}s are: $_dynlist."
		printf "Which one %s? (or 'done') " "$_query"
		[ -n "$_dyndef" ] && printf "[%s] " "$_dyndef"
		_ask || continue
		[ -z "$resp" ] && resp="$_dyndef"

		# Quote $resp to prevent user from confusing isin() by
		# entering something like 'a a'.
		isin "$resp" $_dynlist done && break
		echo "'$resp' is not a valid choice."
	done
}

find_modloop_media() {
	devnum=$(mountpoint -d /.modloop) || return
	test -n "$devnum" || return
	modloop_file=$(cat /sys/dev/block/$devnum/loop/backing_file) || return
	test -n "$modloop_file" || return
	# assume that device name and mount point don't contain spaces
	modloop_media=$(df "$modloop_file" | awk 'NR==2{print $6}') || return
	test -n "$modloop_media" || return
	echo "$modloop_media"
}

# Extract fully qualified domain name from current hostname. If none is
# currently set, use the provided fallback.
get_fqdn() {
	local _dn
	_dn=$(hostname -f 2>/dev/null)
	_dn=${_dn#$(hostname -s 2>/dev/null)}
	_dn=${_dn#.}
	echo "${_dn:=$1}"
}




again here's the full /sbin/setup-desktop script

#!/bin/sh

PREFIX=@PREFIX@
: ${LIBDIR=$PREFIX/lib}
. "$LIBDIR/libalpine.sh"

usage() {
	cat <<-__EOF__
		usage: setup-desktop [-h] [gnome|plasma|xfce|mate|sway]

		Install a standard desktop

		options:
		 -h  Show this help

	__EOF__
	exit $1
}

while getopts "h" opt; do
	case $opt in
		h) usage 0;;
		'?') usage "1" >&2;;
	esac
done
shift $(($OPTIND - 1))

if [ $# -gt 1 ]; then
	usage "1" >&2
fi

if [ $# -eq 0 ]; then
	users=$(awk -F: '{if ($3<65000 && $3 >= 1000) print $1}' "$ROOT"/etc/passwd 2>/dev/null)
	if [ -z "$users" ]; then
		setup-user -g "audio,video,netdev"
	fi
fi

de="$1"

valid_desktops="xfce gnome plasma mate sway none"
if [ $# -eq 1 ] && ! isin "$de" $valid_desktops; then
	echo "$de is not a valid desktop" >&2
	usage "1" >&2
fi
shift

while ! isin "$de" $valid_desktops; do
	ask "Which desktop environment? ('gnome', 'plasma', 'xfce', 'mate', 'sway' or 'none')" none
	de="$resp"
done

case "$de" in
	none)
		exit 0
		;;
	mate)
		setup-xorg-base mate-desktop-environment ${BROWSER:-firefox} \
			consolekit2 \
			gvfs \
			lightdm \
			lightdm-gtk-greeter \
			polkit \
			dbus \
			dbus-x11 \
			font-dejavu \
			"$@"
		rc-update add dbus
		rc-update add lightdm
		;;
	xfce)
		setup-xorg-base xfce4 ${BROWSER:-firefox} \
			consolekit2 \
			gvfs \
			lightdm \
			lightdm-gtk-greeter \
			polkit \
			xfce4-terminal \
			"$@"
		rc-update add lightdm
		;;
	gnome)
		setup-xorg-base ${BROWSER:-firefox} "$@"
		# apk info needs community repos which are enabled with setup-xorg-base
		apk add $(apk info --quiet --depends gnome gnome-apps-core)
		rc-update add gdm
		rc-update add elogind
		;;
	plasma)
		setup-xorg-base ${BROWSER:-firefox} \
			ark \
			bluedevil \
			breeze \
			breeze-gtk \
			dbus \
			discover \
			drkonqi \
			font-noto \
			gwenview \
			kate \
			kde-cli-tools \
			kde-gtk-config \
			kde-icons \
			kdeplasma-addons \
			kgamma \
			kinfocenter \
			kio-fuse \
			kmenuedit \
			konsole \
			kscreen \
			ksshaskpass \
			kwallet-pam \
			kwayland-integration \
			pinentry-qt \
			pipewire-alsa \
			pipewire-pulse \
			plasma-browser-integration \
			plasma-desktop \
			plasma-disks \
			plasma-nm \
			plasma-pa \
			plasma-systemmonitor \
			plasma-vault \
			plasma-welcome \
			plasma-workspace-wallpapers \
			polkit-elogind \
			polkit-kde-agent-1 \
			powerdevil \
			print-manager \
			sddm-breeze \
			sddm-kcm \
			spectacle \
			systemsettings \
			udisks2 \
			xdg-desktop-portal-kde \
			xdg-user-dirs \
			"$@"
		rc-update add dbus
		rc-update add sddm
		;;
	sway)
		setup-wayland-base ${BROWSER:-firefox} \
			dmenu \
			font-dejavu \
			foot \
			grim \
			i3status \
			sway \
			swayidle \
			swaylockd \
			util-linux-login \
			wl-clipboard \
			wmenu \
			xwayland \
			"$@"
		;;
	*)
		usage "1" >&2
		;;
esac

users=$(awk -F: '{if ($3<65000 && $3 >= 1000) print $1}' "$ROOT"/etc/passwd 2>/dev/null)
if [ -z "$users" ]; then
	echo "WARNING: You need to create a user account. Please run: setup-user" >&2
	echo "" >&2
fi

ok here's the startxfce4 script which i need to modify because it's crashing again and trying to start xinit instead ( which we obviously dont have)


if test
"×$*" ?= "x"
then
OPTS=***•
for OPT in S* do
if test
"x$OPT" = "x--help"
then
# print help
echo
ntsage?,, and exit
echo "
startxfce4 [OPTIONS...]"
echo echo echo echo
"Options:"
--help
—-with-ck-launch
echo echo
Show help options"
Start xfce4-session inside a"
ConsoleKit session"
exit 0
elif test
"x$OPT" = "x--with-ck-launch"
then
# try to launch xfce4-session with ck-launch-session in xinitrc
XFCE4_SESSION_WITH_CK="1"
export XFCE4_SESSION_WITH_CK
else
# append
OPTS="$OPTS SOPT"
fi done
if test then
CLIENTRC=$(OPTS}
else
SERVERRC=$(OPTS#*- }
CLIENTRC=$(OPTS%--*}
"x$COPTS#*-]" = "x$(OPTS]"
fi fi
if test then
else
"X$XDG_CONFIG _HOME" = "x"
BASEDIR="$HOME/ .config/xfce4/"
BASED IR="$XDG_CONFIG_HOME/xfce4"
fi
if test "x$XDG_DATA DIRS" = "x"
then
"EDAT.DS=S/1cal/Shate:/st/Share""susr/share"="x/ust/share" then
else
XDG_DATA_DIRS="/usr/Share:/usr/local/share:/usr/share"
fi
If SXDG_DATA_DIRS is pre-defined, but does not end with /usr/share, append it elif test
"$EXDG_DATA_DIRS##*:}" !=
"/usr/share"
then
XDG _DATA_DIRS="SDG_DATA_DIRS:/usr/share"
fi export XDG_DATA_DIRS
if test "x$XDG_CONFIG_DIRS" = "x"
then
if test "x/etc" = "x/etc"; then
XDG_CONFIG_DIRS="/etc/xdg"
else
XDG_CONFIG_DIRS="/etc/xdg :/etc/xdg"
fi
If $XDG_CONFIG_DIRS is pre-defined, but does not end with /etc/xdg, append it elif test
"SEXDG CONFIG DIRS##*:3"
!= "/etc/xdg"
then
XDG_CONFIG_DIRS="DG_CONFIG_DIRS: /etc/xdg"
fi export XDG_CONFIG_DIRS
if test "x$DISPLAY" = "x"
then
echo "$0: Starting X server"
prog-xinit
if test ! "x$XDG_VTNR" = "x"; then
SERVERRC="$SERVERRC vt$XDG_UTN"
fi else echo
"$o: X server already ruming on display $DISPLAY"
prog=/bin/sh
fi
if [ -f "SHOME/.xserverrc" 1: then
SERVERRC="SHOME/ xserverre $SERVERRC"
elif I -f /etc/X11/xinit/xserverrc 1; then
SERVERRC="/etc/X11/xinit/xserverrc $SERVERRC"
fi

if test ? "x$SERVERRC" = "x"
then
SERVERRC="-- $SERVERRC"
fi
if [ -f $BASEDIR/xinitrc ]; then exec $prog $BASEDIR/xinitrc $CLIENTRC $SERUERRC elif [ -f $HOME/.xfce4/xinitrc ]; then
mkdir -p $BASEDIR cp SHOME/ .xfce4/xinitrc $BASEDIR/ exec Sprog $BASEDIR/xinitrc $CLIENTRC $SERVERRC else
exec Sprog /etc/xdg/xfce4/xinitrc SCLIENTRC $SERVERRC
fi


Keep in mind for my last piece of code for startxfce my OCR may be inaccurate as often $HOME is written as SHOME etc

but again I wanna modify stuff it so i can use wayland with xfce instead