#!/bin/sh
# Arctic Linux - audio.
# pipewire is a per-session daemon, so this only makes sure the system pieces
# exist; the user session starts the daemon itself.
NAME=pipewire
case "${1:-}" in
start)
	modprobe snd-seq 2>/dev/null || :
	install -d -m 0755 /run/pipewire
	exit 0 ;;
stop|restart) exit 0 ;;
status)
	# Not "pgrep -x pipewire": this script is itself named pipewire, and the
	# kernel sets an interpreted script's comm to the script's own basename,
	# so a plain name match here would find this status check's own process
	# and report "running" unconditionally, real daemon or not (the same
	# trap svc.lib's svc_running works around for every other service).
	for d in /proc/[0-9]*; do
		[ "$(readlink "$d/exe" 2>/dev/null)" = /usr/bin/pipewire ] && exit 0
	done
	exit 1 ;;
*) echo "usage: $0 start|stop|restart|status" >&2; exit 2 ;;
esac
