#!/bin/bash
# chkconfig: 35 99 20
# description: Set ALSA-MIDI ports - TiMidity++
#
### BEGIN INIT INFO
# Provides: alsa2midi
# Default-Start: 3 5
# Default-Stop: 0 2 1 6
# Description:  Set ALSA-MIDI ports - TiMidity++
### END INIT INFO
# Required-Start: 
# Required-Stop: 
# /sbin/chkconfig --add alsa2midi
# /sbin/chkconfig --list alsa2midi
# for TiMidity++

. /etc/rc.d/init.d/functions
RETVAL=0

start() {
	timidity --sequencer-ports=4 -iAD
	echo -n $"TiMidity: 4 MIDI ports registered to ALSA-sequencer."
	echo
}

stop() {
	killall timidity
	echo -n $"TiMidity: process stopped. "
	echo
}

midi_status() {
	echo $"TiMidity:ALSA - aplaymidi --list.(ALSA midi-play)"
	aplaymidi -l
	echo
}

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	status)
		midi_status
		;;
	restart)
		stop
		start
		;;
	*)
		echo $"Usage: $prog {start|stop|status|restart}"
		exit 1
esac
exit $RETVAL
