From e7b9c8dc02d02c28488102381e96e6ad20f49ef7 Mon Sep 17 00:00:00 2001 From: lightship Date: Sun, 24 May 2020 16:32:30 -0700 Subject: [PATCH] Add audio out menu Signed-off-by: Miles Alan --- scripts/core/sxmo_appmenu.sh | 1 + scripts/core/sxmo_audiooutmenu.sh | 30 ++++++++++++++++++++++++++++++ scripts/core/sxmo_vol.sh | 8 ++++---- 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100755 scripts/core/sxmo_audiooutmenu.sh diff --git a/scripts/core/sxmo_appmenu.sh b/scripts/core/sxmo_appmenu.sh index de6c817..89f2293 100755 --- a/scripts/core/sxmo_appmenu.sh +++ b/scripts/core/sxmo_appmenu.sh @@ -52,6 +52,7 @@ programchoicesinit() { Bar Toggle ^ 1 ^ key Alt+b Rotate ^ 1 ^ rotate Wifi ^ 0 ^ st -e "nmtui" + Audio Out ^ 0 ^ sxmo_audiooutmenu.sh Upgrade Pkgs ^ 0 ^ st -e sxmo_upgrade.sh ")" && WINNAME=Config && return diff --git a/scripts/core/sxmo_audiooutmenu.sh b/scripts/core/sxmo_audiooutmenu.sh new file mode 100755 index 0000000..c6a75c6 --- /dev/null +++ b/scripts/core/sxmo_audiooutmenu.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env sh +pidof svkbd-sxmo || svkbd-sxmo & + +OUTINPUT="$( +echo "speaker +headphones +earpiece +none +Close Menu" | dmenu -p "Audio Out" -c -fn "Terminus-30" -l 20 +)" + +pkill svkbd-sxmo +[[ "Close Menu" == "$OUTINPUT" ]] && exit 0 + +SPEAKER="Line Out" +HEADPHONE="Headphone" +EARPIECE="Earpiece" + +amixer set "$SPEAKER" mute > /dev/null +amixer set "$HEADPHONE" mute > /dev/null +amixer set "$EARPIECE" mute > /dev/null + +if [[ "$OUTINPUT" = "speaker" ]]; then + amixer set "$SPEAKER" unmute > /dev/null +elif [[ "$OUTINPUT" = "headphones" ]]; then + amixer set "$HEADPHONE" unmute > /dev/null +elif [[ "$OUTINPUT" = "earpiece" ]]; then + amixer set "$EARPIECE" unmute > /dev/null +fi + diff --git a/scripts/core/sxmo_vol.sh b/scripts/core/sxmo_vol.sh index a08edcf..7292789 100755 --- a/scripts/core/sxmo_vol.sh +++ b/scripts/core/sxmo_vol.sh @@ -1,7 +1,7 @@ #!/usr/bin/env sh device() { amixer sget Earpiece | grep -E '[[]on[]]' > /dev/null && echo Earpiece && return - amixer sget Headphone > /dev/null && echo Headphone || echo Speaker + amixer sget Headphone > /dev/null && echo Headphone || echo "Line Out" } notify() { @@ -16,15 +16,15 @@ notify() { } up() { - amixer set $(device) 1+ + amixer set "$(device)" 1+ notify } down() { - amixer set $(device) 1- + amixer set "$(device)" 1- notify } setvol() { - amixer set $(device) $1 + amixer set "$(device)" $1 } $@