~mil/sxmo-devel

sxmo-utils: Address feedback for audio out menu patch v1 APPLIED

~lightship
 - updated dwm status bar script for speaker
 - removed redirect to
/dev/null when muting and unmuting
 - first letter is capitalized for
choices
 - removed none option for audio output to simplify the status
bar logic
 - updated active device function to not default on headphone
(New to git-email. Patches could, perhaps, be squashed.)

lightship (2):
  Add audio out menu
  Address feedback

 scripts/core/sxmo_appmenu.sh      |  1 +
 scripts/core/sxmo_audiooutmenu.sh | 29 +++++++++++++++++++++++++++++
 scripts/core/sxmo_statusbar.sh    |  9 +++++----
 scripts/core/sxmo_vol.sh          | 11 ++++++-----
 4 files changed, 41 insertions(+), 9 deletions(-)
 create mode 100755 scripts/core/sxmo_audiooutmenu.sh

-- 
2.24.3
Thanks! - applied
Removed the keyboard input check and also touched the watch file for the dwm bar to update with new volume as well.

Might be nice to also have this in a loop and also show a checkmark next to the currently active output.
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~mil/sxmo-devel/patches/10807/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH sxmo-utils 1/2] Add audio out menu Export this patch

~lightship
From: lightship <lightship@git.sr.ht>

---
 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 8497924..557ce22 100755
--- a/scripts/core/sxmo_appmenu.sh
+++ b/scripts/core/sxmo_appmenu.sh
@@ -50,6 +50,7 @@ programchoicesinit() {
    Flash $(cat /sys/class/leds/white:flash/brightness | grep -E '^0$' > /dev/null && echo -n "Off \ufffd\ufffd\ufffd On" || echo -n "On \ufffd\ufffd\ufffd Off") ^ 1 ^ sxmo_flashtoggle.sh
    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
}

$@
-- 
2.24.3

[PATCH sxmo-utils 2/2] Address feedback Export this patch

~lightship
From: lightship <lightship@git.sr.ht>

---
 scripts/core/sxmo_audiooutmenu.sh | 25 ++++++++++++-------------
 scripts/core/sxmo_statusbar.sh    |  9 +++++----
 scripts/core/sxmo_vol.sh          |  5 +++--
 3 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/scripts/core/sxmo_audiooutmenu.sh b/scripts/core/sxmo_audiooutmenu.sh
index c6a75c6..b08e7a3 100755
--- a/scripts/core/sxmo_audiooutmenu.sh
+++ b/scripts/core/sxmo_audiooutmenu.sh
@@ -2,10 +2,9 @@
pidof svkbd-sxmo || svkbd-sxmo &

OUTINPUT="$(
echo "speaker
headphones
earpiece
none
echo "Speaker
Headphones
Earpiece
Close Menu" | dmenu -p "Audio Out" -c -fn "Terminus-30" -l 20
)"

@@ -16,15 +15,15 @@ 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
amixer set "$SPEAKER" mute
amixer set "$HEADPHONE" mute
amixer set "$EARPIECE" mute

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
if [[ "$OUTINPUT" = "Speaker" ]]; then
  amixer set "$SPEAKER" unmute
elif [[ "$OUTINPUT" = "Headphones" ]]; then
  amixer set "$HEADPHONE" unmute
elif [[ "$OUTINPUT" = "Earpiece" ]]; then
  amixer set "$EARPIECE" unmute
fi

diff --git a/scripts/core/sxmo_statusbar.sh b/scripts/core/sxmo_statusbar.sh
index d4852d8..1e75979 100755
--- a/scripts/core/sxmo_statusbar.sh
+++ b/scripts/core/sxmo_statusbar.sh
@@ -2,8 +2,9 @@
pgrep -f sxmo_statusbar.sh | grep -v $$ | xargs kill -9

audiodevice() {
  amixer sget Earpiece | grep -E [[]on[]] && echo Earpiece > /dev/null && return
  amixer sget Headphone > /dev/null && echo Headphone || echo Speaker
  amixer sget Earpiece | grep -E '\[on\]' > /dev/null && echo Earpiece && return
  amixer sget Headphone | grep -E '\[on\]' > /dev/null && echo Headphone && return
  echo "Line Out"
}

sleep 1
@@ -25,7 +26,7 @@ do

        # Volume
        VOL=$(
                echo "$(amixer sget $(audiodevice))" |
                echo "$(amixer sget "$(audiodevice)")" |
                grep -oE '([0-9]+)%' |
                tr -d ' %' |
                awk '{ s += $1; c++ } END { print s/c }'  |
@@ -40,4 +41,4 @@ do

        inotifywait -e MODIFY $UPDATEFILE & sleep 30 & wait -n
        pgrep -P $$ | xargs kill -9
done
\ No newline at end of file
done
diff --git a/scripts/core/sxmo_vol.sh b/scripts/core/sxmo_vol.sh
index 7292789..7b1e581 100755
--- a/scripts/core/sxmo_vol.sh
+++ b/scripts/core/sxmo_vol.sh
@@ -1,7 +1,8 @@
#!/usr/bin/env sh
device() {
  amixer sget Earpiece | grep -E '[[]on[]]' > /dev/null && echo Earpiece && return
  amixer sget Headphone > /dev/null && echo Headphone || echo "Line Out"
  amixer sget Earpiece | grep -E '\[on\]' > /dev/null && echo Earpiece && return
  amixer sget Headphone | grep -E '\[on\]' > /dev/null && echo Headphone && return
  echo "Line Out"
}

notify() {
-- 
2.24.3
Thanks! - applied
Removed the keyboard input check and also touched the watch file for the dwm bar to update with new volume as well.

Might be nice to also have this in a loop and also show a checkmark next to the currently active output.