#!/sbin/openrc-run

# TODO: Don't think we need this one
DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus"
export DBUS_SESSION_BUS_ADDRESS
output_logger="logger"
error_logger="logger"

supervisor=supervise-daemon
description="GNOME Shell (wayland)"
command="/usr/bin/gnome-shell"
command_args="--wayland"
pidfile="${XDG_RUNTIME_DIR}/gnome-shell-wayland.pid"
_gsl_file="${XDG_RUNTIME_DIR}/gnome-session-leader.pid"

start_pre()
{
	if ! [ -f ${_gsl_file} ] ; then
		eerror "${_gsl_file} doesn't exist, which means you probably started"
		eerror "this manually, or the gnome-session openrc leader broke."
		return 1
	fi

	# Now we'll get the environ from that
	while read -d $'\0' line ; do
		export "${line}"
	done < /proc/$(cat ${_gsl_file})/environ
}
