* antiX does not currently pre-install an audio equalizer GUI app
* the few equalizer apps available from debian jessie repo all depend on systemd!
* it's lean-n-mean tiny
how to install / test:
1) paste from the two codeboxes shown below into files /usr/local/bin/eekwal_func and /usr/local/bin/eekwal
2) chmod +x both files
3) from a terminal emulator prompt, run"eekwal" (no quotes)
4) (optional, DIY) after testing, if you decide to keep using it, create a .desktop launcher & run"Update Menu"
I've tested, it's working (and I'll keep using it) but the"create/save custom presets" functionality
is undocumented and is either confusing (to me) or is somewhat buggy.
Ideally, IMO, the entrybox should not have an associated as-you-type action;"SaveAs custom" would only be performed when button/icon is clicked.
Code: Select all
#!/bin/bash
# PLACE THIS AS FILE /usr/local/bin/eekwal and chmod +x
#
# THIS SCRIPT IS DERIVED FROM"pEqualizer"
# http://murga-linux.com/puppy/viewtopic.php?t=81889
#
# License: GPLv2 or, at your option, any later version
# 20121028 (c) 01micko@gmail.com and zigbert@murgalinux.com 2011-2012
# Modified for antiX Feb2017
#
# Occupies approx 3Mb RAM while running.
# Feel free to launch, make changes, and exit; changed settings will remain in effect.
#
# NOTE: If a given application provides its own"selected/preferred sound card" pref,
# that preference will override global alsa settings.
# This equalizer utiltity should work for any app which uses the global alsa settings.
# could omit checking this, as libasound_module_ctl_equal.so is provided by
# pkg"libasound2-plugin-equal" (present by default in antiX16)
if [ ! -f /usr/lib/i386-linux-gnu/alsa-lib/libasound_module_ctl_equal.so ] && \
[ ! -f /usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_ctl_equal.so ]; then
echo"Missing dependencies: libasound_module_ctl_equal.so"
echo"equalizer will now exit."
exit 1 ;
fi
# further dependencies (omit checking, as these are pre-installed in antiX16)
# libasound_module_ctl_equal.so (provided by pkg"libasound2-plugin-equal")
# gtkdialog >=0.8.0 (pre-installed package"gtkdialog" provides v0.8.3)
if [[ $UID =="0" ]]; then
echo"equalizer utility is NOT suitable for use by root user"
exit 1 ;
fi
# REF: these are the freq fields recognized by alsaequal
# '01. 31 Hz' '02. 63 Hz' '03. 125 Hz' '04. 250 Hz' '05. 500 Hz'
# '06. 1 kHz' '07. 2 kHz' '08. 4 kHz' '09. 8 kHz' '10. 16 kHz'
#set -x #uncomment this line while debugging
VERSION=0.9.1
#enable alsaequal
[ ! -f $HOME/.asoundrc.bak ] && cat > $HOME/.asoundrc.bak << _EQ
ctl.equal {
type equal;
}
pcm.plugequal {
type equal;
# Modify the line below if you do not want to use sound card 0.
#slave.pcm"plughw:0,0";
# or if you want to use with multiple applications output to dmix
slave.pcm"plug:dmix"
}
#pcm.equal {
# Or if you want the equalizer to be your default soundcard uncomment the following line and comment the above line.
pcm.!default {
type plug;
slave.pcm plugequal;
}
_EQ
mv -f $HOME/.asoundrc.bak $HOME/.asoundrc
#setup working dirs
mkdir /tmp/eekwal 2> /dev/null
[ ! -d $HOME/.config/eekwal/preset ] && mkdir -p $HOME/.config/eekwal/preset
export CONFDIR="$HOME/.config/eekwal"
#create config
[ ! -f $HOME/.config/eekwal/eekwalrc ] && echo '#eekwal config
export PRESET=Flat' > $HOME/.config/eekwal/eekwalrc
#create presets
[ ! -f $CONFDIR/preset/Flat ] && cat > $CONFDIR/preset/Flat << _FLAT
VAL1=65
VAL2=65
VAL3=65
VAL4=65
VAL5=65
VAL6=65
VAL7=65
VAL8=65
VAL9=65
VAL10=65
_FLAT
[ ! -f $CONFDIR/preset/Jazz ] && cat > $CONFDIR/preset/Jazz << _JAZZ
VAL1=53
VAL2=42
VAL3=54
VAL4=58
VAL5=63
VAL6=68
VAL7=74
VAL8=79
VAL9=89
VAL10=79
_JAZZ
[ ! -f $CONFDIR/preset/Pop ] && cat > $CONFDIR/preset/Pop << _POP
VAL1=78
VAL2=67
VAL3=64
VAL4=53
VAL5=53
VAL6=53
VAL7=59
VAL8=64
VAL9=74
VAL10=74
_POP
[ ! -f $CONFDIR/preset/Rock ] && cat > $CONFDIR/preset/Rock << _ROCK
VAL1=68
VAL2=52
VAL3=59
VAL4=63
VAL5=68
VAL6=68
VAL7=69
VAL8=64
VAL9=54
VAL10=54
_ROCK
#read config
. $HOME/.config/eekwal/eekwalrc
#if preset is not valid we need to give a helping hand
if [ !"$PRESET" ] || [ ! -s $HOME/.config/eekwal/preset/$PRESET ]; then
export PRESET=$(ls $HOME/.config/eekwal/preset/ | head -n1)
export PRESETNEW=$PRESET
. /usr/local/bin/eekwal_func -writeconfig
. /usr/local/bin/eekwal_func -preset
fi
#parameters
while [ $# != 0 ]; do
I=1
while [ $I -lt `echo $# | wc -c` ]; do
case $1 in
-e) EMBEDDED=true;;
-s) NOGUI=true;;
-h|--help)
echo 'eekwal alsa audio equalizer
-e Run embedded - gtkdialog code is pointed to stdout
-h Show this help message
-s Setup equalizer - no gui
-v Show eekwal version'
exit;;
-v|--version)
echo"eekwal $VERSION"; exit;;
esac
shift
I=$(($I+1))
done
done
#get/set initial values
/usr/local/bin/eekwal_func -getcurrent
. /tmp/eekwal/valuesrc
["$NOGUI" ="true" ] && exit
. /usr/local/bin/eekwal_func -gui
#build base gui as shown embedded ##### CONSIDER USING BUTTON LABELTEXT VS ICONS
S='
<vbox>
<hbox>
'$SCALES'
</hbox>
<hseparator></hseparator>
<hbox>
<button tooltip-text="Delete preset">
<input file stock="gtk-delete"></input>
<action>/usr/local/bin/eekwal_func -delete"$PRESETNEW"</action>
<action>refresh:PRESETNEW</action>
</button>
<button tooltip-text="Save custom preset (type a new Name or overwrite existing)">
<input file stock="gtk-save"></input>
<action>/usr/local/bin/eekwal_func -save"$PRESETNEW"</action>
<action>refresh:PRESETNEW</action>
</button>
<comboboxentry has-focus="true">
<variable>PRESETNEW</variable>
<default>'$PRESET'</default>
<input>ls -1 '$HOME'/.config/eekwal/preset/</input>
<action>/usr/local/bin/eekwal_func -preset</action>'
for I in 1 2 3 4 5 6 7 8 9 10; do S=$S'<action>refresh:SLIDER'$I'</action>'; done
S=$S'</comboboxentry>
</hbox>
</vbox>'
GUI_EMBEDDED="$S"
if ["$EMBEDDED" ="true" ]; then
echo"$GUI_EMBEDDED"
exit
fi
#show standalone gui ############ NEED TO SPECIFY A KNOWN EXISTING ICONFILE
echo '<window title="audio equalizer" width-request="380" resizable="false">
<vbox>'$GUI_EMBEDDED'</vbox>
<action signal="delete-event">mv -f $HOME/.asoundrc $HOME/.asoundrc.bak</action>
</window>' | gtkdialog -s
Code: Select all
#!/bin/bash
# PLACE THIS AS FILE /usr/local/bin/eekwal_func and chmod +x
case"$1" in
-gui)
COUNT=1
until [ $COUNT = 11 ]; do
case $COUNT in #labels
1) FR="31Hz"; FREQ='01. 31 Hz';;
2) FR="63Hz"; FREQ='02. 63 Hz';;
3) FR="125Hz"; FREQ='03. 125 Hz';;
4) FR="250Hz"; FREQ='04. 250 Hz';;
5) FR="500Hz"; FREQ='05. 500 Hz';;
6) FR="1kHz"; FREQ='06. 1 kHz';;
7) FR="2kHz"; FREQ='07. 2 kHz';;
8) FR="4kHz"; FREQ='08. 4 kHz';;
9) FR="8kHz"; FREQ='09. 8 kHz';;
10) FR="16kHz"; FREQ='10. 16 kHz';;
esac
#<action>echo"'$VARIABLE' is now $'$VARIABLE'"</action> # uncomment for testing
SCALES=$SCALES'
<vbox width-request="28">
<vscale width-request="15" height-request="150" scale-min="0" scale-max="100" scale-step="1" value-pos="2" digits="0" inverted="true">
<input file>/tmp/eekwal/VAL'$COUNT'</input>
<variable>SLIDER'$COUNT'</variable>
<action>amixer -D equal sset '"'$FREQ'"' $SLIDER'$COUNT' >/dev/null 2>&1</action>
<item>"50 | 1"</item>
</vscale>
<text use-markup="true"><label>"<tt><small><small>'${FR}'</small></small></tt>"</label></text>
</vbox>'
COUNT=$(($COUNT+1))
done
;;
-preset)
cp -f $HOME/.config/eekwal/preset/$PRESETNEW /tmp/eekwal/valuesrc
. /tmp/eekwal/valuesrc
eval /usr/local/bin/eekwal_func -links #update images
COUNT=1
for VAL in '01._31_Hz' '02._63_Hz' '03._125_Hz' '04._250_Hz' '05._500_Hz' '06._1_kHz' '07._2_kHz' '08._4_kHz' '09._8_kHz' '10._16_kHz'; do
ACTVAL="`echo"$VAL"|tr '_' ' '`"
case $COUNT in #values
1)SETVAL="$VAL1";;
2)SETVAL="$VAL2";;
3)SETVAL="$VAL3";;
4)SETVAL="$VAL4";;
5)SETVAL="$VAL5";;
6)SETVAL="$VAL6";;
7)SETVAL="$VAL7";;
8)SETVAL="$VAL8";;
9)SETVAL="$VAL9";;
10)SETVAL="$VAL10";;
esac
#echo"amixer -D equal sset"$ACTVAL""$SETVAL"" >> /root/debug #debug remove
amixer -D equal sset"$ACTVAL""$SETVAL" >/dev/null 2>&1 #set mixer, suppress stdout and stderr
echo $SETVAL > /tmp/eekwal/VAL$COUNT
COUNT=$(($COUNT+1))
done
. $0 -writeconfig
;;
-writeconfig)
[ !"$PRESETNEW" ] && exit
echo"#eekwal alsa audio config" > $HOME/.config/eekwal/eekwalrc
echo"export PRESET=$PRESETNEW" >> $HOME/.config/eekwal/eekwalrc
;;
-getcurrent)
#get current values #could be a problematic if surround is enabled
echo"#values" > /tmp/eekwal/valuesrc
CNT=1
for VAL in '01._31_Hz' '02._63_Hz' '03._125_Hz' '04._250_Hz' '05._500_Hz' '06._1_kHz' '07._2_kHz' '08._4_kHz' '09._8_kHz' '10._16_kHz'; do
ACTVAL="`echo"$VAL"|tr '_' ' '`"
PERCENT="`amixer -D equal sget"$ACTVAL" | grep -F"Left:" | cut -d ':' -f2 | cut -d' ' -f3`"
echo"VAL${CNT}=$PERCENT" >> /tmp/eekwal/valuesrc
echo"$PERCENT" > /tmp/eekwal/VAL${CNT}
CNT=$(($CNT+1))
done
#error check and kill
if [ ! -f $HOME/.alsaequal.bin ];then
gtkdialog-splash -close box -bg hotpink -text"An error occurred. Please check your sound configuration."
exit 1
fi
;;
-save)
export PRESETNEW="`echo"$2"| tr ' ' '_'`" #ensure it is only one word
if [ -s $HOME/.config/eekwal/preset/$PRESETNEW ]; then #already exists
export yesno_box='
<window title="audio equalizer" window_position="2" allow-grow="false">
<vbox>
<frame>
<pixmap icon_size="6"><input file stock="gtk-dialog-warning"></input></pixmap>
<text use-markup="true"><label>"<b>Preset <u>'$PRESETNEW'</u> already exists.</b>"</label></text>
<text><label>Do you want to overwrite existing Preset?</label></text>
</frame>
<hbox><button no></button><button yes></button></hbox>
</vbox>
</window>'
I=$IFS; IFS=""
for STATEMENTS in $(gtkdialog -p yesno_box --center); do
eval $STATEMENTS
done
IFS=$I
[ $EXIT = No ] && exit
fi
$0 -getcurrent
cp /tmp/eekwal/valuesrc $HOME/.config/eekwal/preset/$PRESETNEW
. $0 -writeconfig
;;
-delete)
PRESET="$2"
export yesno_box='
<window title="audio equalizer" window_position="2" allow-grow="false">
<vbox>
<frame>
<pixmap icon_size="6"><input file stock="gtk-dialog-warning"></input></pixmap>
<text use-markup="true"><label>"<b>Do you REALLY want to delete the preset named <u>'$PRESET'</u>?</b>"</label></text>
</frame>
<hbox><button no></button><button yes></button></hbox>
</vbox>
</window>'
I=$IFS; IFS=""
for STATEMENTS in $(gtkdialog -p yesno_box --center); do
eval $STATEMENTS
done
IFS=$I
[ $EXIT = No ] && exit
rm $HOME/.config/eekwal/preset/$PRESET
#get a new sane preset
export PRESETNEW=$(ls $HOME/.config/eekwal/preset/ | head -n1)
. $0 -preset
. $0 -writeconfig
;;
esac