#!/bin/bash

# Conmen for Linux, Console menu scripts. (cmsound).
# Copyright (C) 1999  Maxim Heijndijk

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

# Email: cchq@wanadoo.nl"

MNAME=cmsound

. /usr/lib/conmen/cmfunk

for FILE in /usr/lib/conmen/${MNAME}/*[!~] ; do
    . ${FILE}
done

. $GLOBALRC
. $USERRC

# Warn if the Xdialog wrapper is not installed.
if_no_wrapper

if [ -f "/etc/conmen/"$MNAME"rc" ] ; then
    . /etc/conmen/"$MNAME"rc
else
    yesnobox "You have not configured a soundcard yet, would like to configure one now ?"
    [ "$YNRETVAL" = "0" ] && configure_sound || exit 0
fi

if [ -f "/etc/conf.modules" ] ; then
    CONFIGFILE=/etc/conf.modules
else
    CONFIGFILE=/etc/modules.conf
fi

function sound {
    MENU="SOUND MENU"
    OSSDRIVER=`which soundon 2> /dev/null`
    case $SOUNDCARD in
	emu10k1) EMU=("A" "ACTIVATE SBLIVE WITH ALSA DRIVERS" \
	              "A1" "ACTIVATE SBLIVE WITH CREATIVE DRIVER");;
	sbawe)	 AWE=("A" "ACTIVATE SBAWE WITH ALSA DRIVERS");;
#		      "A2" "SBAWE OSSLITE DRIVERS")
	sb16)	 SB16=("A" "ACTIVATE SB16 WITH ALSA DRIVERS" \
		       "A3" "ACTIVATE SB16 WITH OSSLITE DRIVERS");;
    esac
    if [ -L  "$OSSDRIVER" ]; then
	OSSD=("B" "OSS COMMERCIAL DRIVERS" \
	      "C" "OSS CONFIGURE SOUNDCARD")
    fi
    THE_REST=("D" "KONSOLE MIXER" \
	      "E" "CHANGE SETTINGS" \
	      "F" "REMOVE ALL MODULES" \
	      "G" "LIST MODULES" \
	      "H" "VIEW OR EDIT $CONFIGFILE" \
	      "I" "CHMOD 666 ON AUDIO DEVICES")
    menubox "${EMU[@]}" "${AWE[@]}" "${SB16[@]}" "${OSSD[@]}" "${THE_REST[@]}"
}

sound

exit 0