#!/bin/sh

[ -n "$*" ] || exit

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