#!/bin/zsh
setopt no_unset xtrace
xpra_display=${1#:}
shift

export XAUTHORITY=/run/Xauthority.$xpra_display
truncate -s 0 $XAUTHORITY || exit $?
{ printf "add :%d . " $xpra_display; busybox xxd -p -l 16 </dev/urandom } | xauth -f $XAUTHORITY || exit $?

args=(
	--attach=no
	--minimal=yes
	--audio=no
	--bell=yes
	--clipboard=no
	--daemon=no
	--dbus-control=no
	--dbus-launch=
	# --dbus-proxy=no
	--file-transfer=no
	--forward-xdg-open=False
	--keyboard-raw=yes
	--mdns=no
	--notifications=no
	--open-files=no
	--open-url=no
	--printing=no
	--systemd-run=no
	--xvfb="${commands[xpra-launch-xorg]} /run/service/xpra-xorg.$xpra_display"
)
exec xpra start "$args[@]" "$@" :$xpra_display