#!/bin/sh

artsplay=artsplay
pulseaudio=pulseaudio
paplay=paplay
esdplay=esdplay

[ -n "$*" ] || exit

if pidof -s artsd >/dev/null; then
	exec $artsplay "$@"
elif $pulseaudio --check 2>/dev/null; then
	PULSE_PROP='media.role=event' exec sox "$@" -t wav - | $paplay
elif [ -S /tmp/.esd-${UID}/socket ]; then
	exec $esdplay "$@"
else
	exec play -v 0.5 "$@"
fi
