summaryrefslogtreecommitdiff
blob: 1ee3aae66c5af0399e8a52200533f627d0a0d7a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash

source /sbin/functions.sh
source /etc/emu10k1.conf

# setup regex strings to match 
AUDIGY_PCI_TAG="multimedia audio controller: creative labs.*audigy"
EMU10K1_PCI_TAG="multimedia audio controller: creative labs.*emu10k1"

# first try to detect via lspci (sys-apps/pciutils)
if [ -z "${CARD_TYPE}" ] && [ -x /sbin/lspci ] ; then
	if [ -n "$(lspci | egrep -i '${AUDIGY_PCI_TAG}')" ] ; then
		CARD_TYPE="audigy"
	elif [ -n "$(lspci | egrep -i '${EMU10K1_PCI_TAG}')" ] ; then
		CARD_TYPE="emu"
	fi
fi

# if that didnt work, lets try via the kernel's /proc/pci interface
if [ -z "${CARD_TYPE}" ] && [ -e /proc/pci ] ; then
	if [ -n "$(egrep -i '${AUDIGY_PCI_TAG}' /proc/pci)" ] ; then
		CARD_TYPE="audigy"
	elif [ -n "$(egrep -i '${EMU10K1_PCI_TAG}' /proc/pci)" ] ; then
		CARD_TYPE="emu"
	fi
fi

# if that failed, make the user tell us what it is
case "`echo ${CARD_TYPE} | awk '{print toupper($1)}'`" in
	AUDIGY)
		audigy-script $@
		;;
	EMU)
		emu-script $@
		;;
	*)
		eerror "I was unable to figure out whether you have an Audigy"
		eerror "or an Emu10k1 sound card.  Further more, you have not"
		eerror "told me what kind of sound card you have."
		eerror "Please edit /etc/emu10k1.conf and set the CARD_TYPE"
		eerror "variable.  You will find it at the top of the file."
		exit 1
		;;
esac