#!/bin/sh

get_pa_sock_path()
{
	PA_SOCK_PATH=$(sockstat | awk -v me=$(whoami) -F'[ \t]+' '
		$1 == me && $2 == "pulseaudio" && $6 ~ /native/ {
			print $6;
			exit 0
		}'
	)
}

get_pa_sock_path
[ -S "$PA_SOCK_PATH" ] && export PULSE_SERVER=unix:$PA_SOCK_PATH && export PULSE_COOKIE="~/.config/pulse/cookie"

export BRAVE_PATH="%%DATADIR%%/brave"
export BRAVE_WRAPPER="$(readlink -f "$0")"
export LIBGL_DRI3_DISABLE=1
/usr/local/bin/brave-watch &
exec "$BRAVE_PATH" --no-sandbox --no-zygote --test-type --v=0 "$@"
