#!/bin/sh

set -ex

mkdir -p ~/.run
export XDG_RUNTIME_DIR="$HOME/.run"

cat << EOF > /weston.ini
[core]
backend=headless-backend.so
xwayland=true
idle-time=0

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

mkdir -p /tmp/.X11-unix
export DISPLAY=:0

WAYLAND_DISPLAY=wayland-0
weston --config="/weston.ini" --socket="$WAYLAND_DISPLAY" &
export WAYLAND_DISPLAY

while [ ! -S /tmp/.X11-unix/X0 ]; do sleep 1; done

"$@"
