#!/bin/zsh
# vim: sts=2 sw=2 et
setopt no_unset warn_create_global
main() {
local container display xsession_cookie
container=mpv.$USER
[[ $container == */* ]] && exit 100
display=${DISPLAY#:}
xsession_cookie=${"$(xauth list $DISPLAY)"##* } || exit $?
s6-sudo /run/cmd.s link $container xsession.$display.$USER run/exec/x11 run/exec/exec || exit $?
s6-sudo /run/cmd.s link xsession.$display.$USER $container tmp/.X11-unix/X$display || exit $?
exec s6-sudo /run/inbox/$container/run/exec/x11 $display $xsession_cookie urxvt
}
typeset -f -t main
main "$@"