#/bin/bash

#first init check for pure systemd, no shim
INITCHECK=$(readlink /usr/sbin/init)
echo $INITCHECK
if [ "$INITCHECK" = "/lib/systemd/systemd" ]; then
        exit 0
fi

#second init check for system-shim configuration
INITCHECK=$(/usr/bin/ps -p 1 -o cmd -h)
echo $INITCHECK
if [ "$INITCHECK" = "/lib/systemd/systemd" ]; then 
	exit 0
fi
#else start them up
echo "start pipewire"
if [ -z "$(pgrep -x pipewire)" ]; then 
	/usr/bin/pipewire &
fi
if [ -z "$(pgrep -x pipewire-pulse)" ]; then
	/usr/bin/pipewire-pulse & 
fi
if [ -z "$(pgrep -x wireplumber)" ]; then
	/usr/bin/wireplumber &
fi

exit 0
