Provides Individual floating, audio level and equaliser (hardware or alsa)controls with mute switches. Each called from a neat six button panel with clear labels. BT, Volume, EQ, Alsa EQ, Mic and Profiles. Each can create many individual controls. Each time you click you select the channel/s to control. BT device must be set as default audio card first using saved Profiles.
Code: Select all
#!/bin/ash
# Copyright [C] 2023 Marcos M Contant
# by stemsee
CARD=$(aplay -l | grep card | yad --title="$(gettext 'Select Sound Card')" --list --column="$(gettext 'Found Cards')" --geometry=500x300+200+200 | awk '{print $2}' | tr -d ':')
[ "$CARD" ] && export CARD || exit
function volumefn {
STAMER=$(amixer -c $CARD scontrols | yad --list --multiple --column="$(gettext 'Select Master')" --width=300 --height=300 | cut -f2 -d"'" | sed -e "s/^/'/" -e "s/$/'/") ##"'Playback Digital'"
[ ! "$STAMER" ] && exit || export STAMER
cnt=1
echo "$STAMER" | while read MASTER
do
function mutefn {
amixer -c "$CARD" set "$1" mute
}; export -f mutefn
function fnunmute {
amixer -c "$CARD" set "$1" unmute
}; export -f fnunmute
function volleft {
amixer -c "$CARD" set "$MASTER" frontleft ${2}%
}; export -f volleft
function volright {
amixer -c "$CARD" set "$MASTER" frontright ${2}%
}; export -f volright
export Vol=$(amixer -c $CARD get "$MASTER" | awk -v FS="[[%]" '/%/ {print $2}')
IT="$(echo $RANDOM)"
yad --plug="$IT" --tabnum=1 --text="$(gettext 'Left Volume')" --scale --vertical --print-partial --value="$Vol" | while read line; do volleft "$MASTER" "$line"; sleep 0.01; done &
yad --plug="$IT" --tabnum=2 --text="$(gettext 'Right Volume')" --scale --vertical --print-partial --value="$Vol" | while read line; do volright "$MASTER" "$line"; sleep 0.01; done &
yad --mouse --title="$MASTER $cnt" --window-icon="$camino/icons/speaker.png" --paned --width=220 --buttons-layout=center --height=340 --key=$IT --tab="Vol Left" --tab="Vol Right" --splitter=110 --orient=hor --button="+/-$(gettext 'Mute')":"bash -c \"mutefn $MASTER \"" --button="+/-$(gettext 'Mute')":"bash -c \"fnunmute $MASTER \"" &
cnt=$((cnt + 1))
done
}; export -f volumefn
function aeqfn {
AEQ=$(amixer -D equal | grep Simple | yad --list --multiple --column=SelectMaster --width=300 --height=300 | cut -f2 -d"'" | sed -e "s/^/'/" -e "s/$/'/")
[ ! "$AEQ" ] && exit || export AEQ
cnt=1
echo "$AEQ" | while read -r LEFT
read -r RIGHT
do
export LEFT RIGHT
function aeqvolleft {
amixer -D equal set "$LEFT" ${2}%
}; export -f aeqvolleft
function aeqvolright {
amixer -D equal set "$RIGHT" ${2}%
}; export -f aeqvolright
export aeqVolL=$(amixer -D equal get "$LEFT" | awk -v FS="[[%]" '/%/ {print $2}')
export aeqVolR=$(amixer -D equal get "${RIGHT}" | awk -v FS="[[%]" '/%/ {print $2}')
IT="$(echo $RANDOM)"
yad --plug="$IT" --tabnum=1 --text="$LEFT" --scale --vertical --print-partial --value="$aeqVolL" | while read line; do aeqvolleft "$LEFT" "$line"; sleep 0.01; done &
yad --plug="$IT" --tabnum=2 --text="$RIGHT" --scale --vertical --print-partial --value="$aeqVolR" | while read line; do aeqvolright "$RIGHT" "$line"; sleep 0.01; done &
yad --mouse --title="$(gettext 'Alsa Equaliser') $cnt" --window-icon="$camino/icons/speaker.png" --paned --width=220 --buttons-layout=center --height=340 --key=$IT --tab="Vol Left" --tab="Vol Right" --splitter=110 --orient=hor --no-buttons &
cnt=$((cnt + 1))
done
}; export -f aeqfn
function eqfn {
unset EQ
EQ=$(amixer -c $CARD scontrols | yad --list --multiple --column=SelectMaster --width=300 --height=300 | cut -f2 -d"'" | sed -e "s/^/'/" -e "s/$/'/") ##"'Playback Digital'"
[ ! "$EQ" ] && exit || export EQ
cnt=1
echo "$EQ" | while read -r LEFT
read -r RIGHT
do
export LEFT RIGHT
function eqmutefn {
amixer -c "$CARD" set 'DAC EQ' unmute
}; export -f eqmutefn
function equnmute {
amixer -c "$CARD" set 'DAC EQ' mute
}; export -f equnmute
function eqvolleft {
amixer -c "$CARD" set "$LEFT" ${2}%
}; export -f eqvolleft
function eqvolright {
amixer -c "$CARD" set "$RIGHT" ${2}%
}; export -f eqvolright
export eqVolL=$(amixer -c $CARD get "$LEFT" | awk -v FS="[[%]" '/%/ {print $2}')
export eqVolR=$(amixer -c $CARD get "${RIGHT}" | awk -v FS="[[%]" '/%/ {print $2}')
IT="$(echo $RANDOM)"
yad --plug="$IT" --tabnum=1 --text="$LEFT" --scale --vertical --print-partial --value="$eqVolL" | while read line; do eqvolleft "$LEFT" "$line"; sleep 0.01; done &
yad --plug="$IT" --tabnum=2 --text="$RIGHT" --scale --vertical --print-partial --value="$eqVolR" | while read line; do eqvolright "$RIGHT" "$line"; sleep 0.01; done &
yad --mouse --title="$(gettext 'Hardware Equaliser') $cnt" --window-icon="$camino/icons/speaker.png" --paned --width=220 --buttons-layout=center --height=340 --key=$IT --tab="Vol Left" --tab="Vol Right" --splitter=110 --orient=hor --button="+$(gettext 'Mute')":"bash -c \"eqmutefn $LEFT \"" --button="-$(gettext 'Mute')":"bash -c \"equnmute $RIGHT \"" &
cnt=$((cnt + 1))
done
}; export -f eqfn
function volmicfn {
PHONE=$(amixer -c $CARD scontrols | yad --list --multiple --column=$(gettext 'Select Microphone') --width=300 --height=400 | cut -f2 -d"'" | sed -e "s/^/'/" -e "s/$/'/")
[ ! "$PHONE" ] && exit || export PHONE
cnt=1
echo "$PHONE" | while read MIC
do
export tVolM=$(amixer -c $CARD get "$MIC" | awk -v FS="[[%]" '/%/ {print $2}')
amixer -c '"$CARD"' set "$MIC" ${VolM}%
function tmutefn {
amixer -c "$CARD" set "$1" toggle
}; export -f tmutefn
function tunmute {
amixer -c "$CARD" set "$1" toggle
}; export -f tunmute
function tvolleft {
amixer -c "$CARD" set "$1" frontleft ${2}%
}; export -f tvolleft
function tvolright {
amixer -c "$CARD" set "$1" frontright ${2}%
}; export -f tvolright
function doitMICfn {
amixer -c "$CARD" set "$1" toggle
}; export -f doitMICfn
IT="$(echo $RANDOM)"
yad --plug=$IT --tabnum=1 --scale --vertical --print-partial --value="$tVolM" | while read line; do tvolleft "$MIC" "$line"; tvolright "$MIC" "${line}"; sleep 0.01; done &
TEST=$(amixer -c $CARD get "$MIC" | grep off)
[ -z "$TEST" ] && export STATE="$(gettext 'UnMuted')" || export STATE="$(gettext 'Muted')"
yad --plug=$IT --tabnum=2 --form --columns=1 --field='!gtk-ok!:fbtn' '@sh -c "case %2 in UnMuted|on]) echo 2:Muted;doitMICfn "$MIC";; Muted|off]) echo 2:UnMuted;doitMICfn "$MIC";; esac "' --field=':RO' "$STATE" &
yad --mouse --title="$MIC $cnt" --window-icon="$camino/icons/speaker.png" --paned --width=110 --height=340 --key=$IT --tab=Vol --tab=mute --splitter=30 --orient=ver --no-buttons &
cnt=$((cnt + 1))
done
}; export -f volmicfn
function volbtfn {
TB=$(amixer -M scontrols | grep -v 'Battery' | yad --list --multiple --column=SelectMaster --width=300 --height=200 | cut -f2 -d"'" | sed -e "s/^/'/" -e "s/$/'/") ##"'Playback Digital'"
[ ! "$TB" ] && exit || export TB
cnt=1
echo "$TB" | while read BT
do
function mutebtfn {
amixer -M set "$BT" mute
}; export -f mutebtfn
function fnbtunmute {
amixer -M set "$BT" unmute
}; export -f fnbtunmute
function volleftbt {
amixer -M set "$BT" frontleft ${2}%
}; export -f volleftbt
function volrightbt {
amixer -M set "$BT" frontright ${2}%
}; export -f volrightbt
export Vol=$(amixer -M get "$BT" | awk -v FS="[[%]" '/%/ {print $2}')
IT="$(echo $RANDOM)"
yad --plug="$IT" --tabnum=1 --text="$(gettext 'Left Vol')" --scale --vertical --print-partial --value="$Vol" | while read line; do volleftbt "$BT" "$line"; sleep 0.01; done &
yad --plug="$IT" --tabnum=2 --text="$(gettext 'Right Vol')" --scale --vertical --print-partial --value="$Vol" | while read line; do volrightbt "$BT" "$line"; sleep 0.01; done &
yad --mouse --title="$BT $cnt" --window-icon="$camino/icons/speaker.png" --paned --width=220 --buttons-layout=center --height=340 --key=$IT --tab="Vol Left" --tab="Vol Right" --splitter=110 --orient=hor --button="+$(gettext 'Mute')":"bash -c mutebtfn" --button="-$(gettext 'Mute')":"bash -c fnbtunmute" &
cnt=$((cnt + 1))
done
}; export -f volbtfn
function profiles {
ls /root/.config/snapp/profiles/*.asoundrc | yad --title="$(gettext 'Set Default Audio Card')" --geometry="400x140+200+200" --undecorated --skip-taskbar --no-buttons --list --column="$(gettext 'Choose Audio Card Profile')" --select-action="bash -c \"cp -f "%s" /root/.asoundrc \"" &
}; export -f profiles
yad --on-top --undecorated --button="BT":"bash -c volbtfn" --button="$(gettext 'Volume')":"bash -c volumefn" --button="EQ":"bash -c eqfn" --button="Alsa EQ":"bash -c aeqfn" --button="Mic":"bash -c volmicfn" --button="$(gettext 'Profiles')":"bash -c profiles" --on-top &