XSPLASH_OPTS=""

if [ "$(exorint_param 'services\splash_bar\enabled')" = "false" ]; then
	XSPLASH_OPTS="$XSPLASH_OPTS --no-progress-bar"
fi

if [ "$(exorint_param 'options\splash\disable_touch')" = "true" ]; then
	XSPLASH_OPTS="$XSPLASH_OPTS --no-touch"
fi

if [ ! "$(exorint_fparam 'services\device_restore\enabled')" = "false" ]; then
	XSPLASH_OPTS="$XSPLASH_OPTS --enable-device-restore"
fi

exorint_winserver_wait 10
ret=$?

# BSP-7823 be sure to close psplash before launching xsplash
TMPDIR=/mnt/.boot-psplash /usr/bin/psplash-write "QUIT"

[ $ret -eq 0 ] || exit 0

if [ -e "$XDG_RUNTIME_DIR/wayland-0" ]; then
	chown -R root:video "$XDG_RUNTIME_DIR"
	chmod 770 "$XDG_RUNTIME_DIR"
	chmod 770 "$XDG_RUNTIME_DIR/wayland-0"

        export QT_QPA_PLATFORM=wayland
fi

TMPDIR=/mnt/.psplash /usr/bin/xsplash --boot --infinite-progress $XSPLASH_OPTS &

# Xsplash may set the xrandr rotation, doing this while metacity starts
# can cause issues so wait for a bit.
usleep 500000
