#!/bin/sh

# Terminate running pipewire session
pkill -u "${USER}" -x pipewire\|wireplumber 1>/dev/null 2>&1

# Launch the core daemon
pipewire &

# wait for pipewire to start before attempting to start related daemons
while [ -z "$(pgrep -x pipewire)" ]; do
    sleep 1
done

# Then the pulseaudio daemon
pipewire -c pipewire-pulse.conf &

# Lastly the session manager
exec wireplumber
