#!/bin/bash
#
# alsadecode.sh v1.1 2006/07
#
# script for decoding and playing audio files with different programs
# chosen according to the file's extension.
#
# requires ogg123, mpg321 and aplay or equivalently working command
# line media players.
#
# Copyright (C) 2004-2006 by Pedro Venda < pjvenda (at) pjvenda org >
#
# Distributed under the terms of the GNU Public License Agreement (GPLv2)
# http://www.fsf.org/licensing/licenses/gpl.html or
# http://www.fsf.org/licensing/licenses/gpl.txt
#
# Changelog
# =========
#
# v1.0 - 2004/11
# - initial version
#
# v1.1 - 2006/07/01
# - small cleanups
# - some variables to make script easier to read
#

OGG_PLAYER=/usr/bin/ogg123
MP3_PLAYER=/usr/bin/mpg321
WAV_PLAYER=/usr/bin/aplay
SED=/usr/bin/sed

case `echo ${1} | ${SED} -re "s/.*\.(.*)$/\1/"` in
	ogg)
		echo "playing ogg ${1}"
		${OGG_PLAYER} ${1}
	;;
	mp3|mpg|mpeg)
		echo "playing mp3 ${1}"
		${MP3_PLAYER} ${1}
	;;
	wav|au)
		echo "playing wav ${1}"
		${WAV_PLAYER} ${1}
	;;
esac
