Migrate audio menu logic to appmenu and add indicator for current out device

This commit is contained in:
Miles Alan 2020-05-26 18:03:43 -05:00
parent e7032a4f7f
commit 3c1fbd9e8d
3 changed files with 22 additions and 12 deletions

View file

@ -51,10 +51,18 @@ programchoicesinit() {
Flash $(cat /sys/class/leds/white:flash/brightness | grep -E '^0$' > /dev/null && echo -n "Off → On" || echo -n "On → Off") ^ 1 ^ sxmo_flashtoggle.sh
Bar Toggle ^ 1 ^ key Alt+b
Rotate ^ 1 ^ sxmo_rotate.sh
Audio Out ^ 0 ^ sxmo_audiooutmenu.sh
Audio Out ^ 0 ^ sxmo_appmenu.sh audioout
Upgrade Pkgs ^ 0 ^ st -e sxmo_upgrade.sh
")" && WINNAME=Config && return
# Audio Out menu
echo $WMCLASS | grep -i "audioout" && CURRENTDEV="$(sxmo_audiocurrentdevice.sh)" && CHOICES="$(echo "
Headphones $([[ "$CURRENTDEV" == "Headphone" ]] && echo "✓") ^ 1 ^ sxmo_audioout.sh Headphones
Speaker $([[ "$CURRENTDEV" == "Line Out" ]] && echo "✓") ^ 1 ^ sxmo_audioout.sh Speaker
Earpiece $([[ "$CURRENTDEV" == "Earpiece" ]] && echo "✓") ^ 1 ^ sxmo_audioout.sh Earpiece
None $([[ "$CURRENTDEV" == "None" ]] && echo "✓") ^ 1 ^ sxmo_audioout.sh None
")"
# MPV
echo $WMCLASS | grep -i "mpv" && CHOICES="$(echo "
Pause ^ 0 ^ key space

View file

@ -0,0 +1,9 @@
#!/usr/bin/env sh
audiodevice() {
amixer sget "Earpiece" | grep -E '\[on\]' > /dev/null && echo Earpiece && return
amixer sget "Headphone" | grep -E '\[on\]' > /dev/null && echo Headphone && return
amixer sget "Line Out" | grep -E '\[on\]' > /dev/null && echo Line Out && return
echo "None"
}
audiodevice

View file

@ -1,12 +1,5 @@
#!/usr/bin/env sh
OUTINPUT="$(
echo "Speaker
Headphones
Earpiece
Close Menu" | dmenu -p "Audio Out" -c -fn "Terminus-30" -l 20
)"
[[ "Close Menu" == "$OUTINPUT" ]] && exit 0
ARG="$1"
SPEAKER="Line Out"
HEADPHONE="Headphone"
@ -16,11 +9,11 @@ amixer set "$SPEAKER" mute
amixer set "$HEADPHONE" mute
amixer set "$EARPIECE" mute
if [[ "$OUTINPUT" = "Speaker" ]]; then
if [[ "$ARG" = "Speaker" ]]; then
amixer set "$SPEAKER" unmute
elif [[ "$OUTINPUT" = "Headphones" ]]; then
elif [[ "$ARG" = "Headphones" ]]; then
amixer set "$HEADPHONE" unmute
elif [[ "$OUTINPUT" = "Earpiece" ]]; then
elif [[ "$ARG" = "Earpiece" ]]; then
amixer set "$EARPIECE" unmute
fi