#!/bin/ash
# jamesbond 2011, 2014, 2019
# updated Fatdog 700 - simplify, remove control, leave with "mixer" functionality only
# 131130 L18L internationalisation

# std localisation stanza
export TEXTDOMAIN=fatdog
. gettext.sh
# performance tweak - use "C" if there is no localisation
! [ -e $TEXTDOMAINDIR/${LANG%.*}/LC_MESSAGES/$TEXTDOMAIN.mo ] &&
! [ -e $TEXTDOMAINDIR/${LANG%_*}/LC_MESSAGES/$TEXTDOMAIN.mo ] && LANG=C

### configuration
APPNAME="$(gettext 'Alsa Equaliser')"
SPOT_HOME=$(awk -F: '$1=="spot" {print $6}' /etc/passwd)
ASOUNDRC=${ASOUNDRC:-$HOME/.asoundrc}

if grep -q ctl.equal $ASOUNDRC 2> /dev/null; then
	if [ $(id -u) -eq 0 ]; then
		# change spot's settings, then copy back to root
		su spot -c "alsamixer -D equal"
		cp $SPOT_HOME/.alsaequal.bin /root
	else
		alsamixer -D equal
	fi
else
	Xdialog --title "$APPNAME" --infobox "$(eval_gettext '$APPNAME turned off, it must be turned on for this to work.')" 0 0 10000
fi

