From: Christian Heller <c.heller@plomlompom.de>
Date: Thu, 1 May 2025 06:21:13 +0000 (+0000)
Subject: Fix;
X-Git-Url: https://plomlompom.com/repos/%22https:/validator.w3.org/static/blog?a=commitdiff_plain;h=20aeac61b44e7db981256061cfcd70a2595a0ceb;p=config

Fix;
---

diff --git a/testing/copy/desktop/home/plom/.local/bin/vol b/testing/copy/desktop/home/plom/.local/bin/vol
index e77a243..2aba150 100755
--- a/testing/copy/desktop/home/plom/.local/bin/vol
+++ b/testing/copy/desktop/home/plom/.local/bin/vol
@@ -5,14 +5,22 @@ cd $(dirname "$0")
 . lib/audio_dev_is_mute
 . lib/print_usage
 
+IDX=0
+TYPE=sink
+if [ "$1" = "mic" ]; then
+    IDX=1
+    TYPE=source
+    shift 1
+fi
 MAX_LOUDNESS=150
 
 FLAG_HELP_SHORT='-h'
 FLAG_HELP_LONG='--help'
 
-USAGE_DESCRIPTION='Set audio volume, or (if called without any arguments) toggle audio device muteness.\n\nAvailable arguments:'
-USAGE_LINES='[COMMAND]\nLOUDNESS'
-USAGE_INDICES='LOUDNESS _help'
+USAGE_DESCRIPTION='Set audio device volume, or (if no LOUDNESS provided) toggle audio device muteness.\n\nAvailable arguments:'
+USAGE_LINES='[mic] [COMMAND]\nLOUDNESS'
+USAGE_INDICES='mic LOUDNESS _help'
+USAGE_DESC_mic='if set, affect microphone rather than speakers'
 USAGE_DESC_LOUDNESS='audio volume to set (as percentage, must be integer)'
 USAGE_DESC__help='display this help and exit'
 USAGE_NAME__help="${FLAG_HELP_SHORT}, ${FLAG_HELP_LONG}"
@@ -20,29 +28,26 @@ USAGE_NAME__help="${FLAG_HELP_SHORT}, ${FLAG_HELP_LONG}"
 error_exit() { abort "Aborting due to $1\n\n$(print_usage)"; }
 
 toggle_mute() {
-    if audio_dev_is_mute; then
+    if $(audio_dev_is_mute "${TYPE}" "${IDX}"); then
         MUTE_BOOL=0
         MUTE_WORD=off
     else
         MUTE_BOOL=1
         MUTE_WORD=on
     fi
-    pacmd set-sink-mute 0 "${MUTE_BOOL}"
-    echo "Toggled audio device muteness ${MUTE_WORD}."
+    pacmd "set-${TYPE}-mute" "${IDX}" "${MUTE_BOOL}"
+    echo "Toggled audio ${TYPE} muteness ${MUTE_WORD}."
 }
 
 set_vol_percentage() {
     AT_FULL=65536
-    pacmd set-sink-volume 0 $(calc "($1 * ${AT_FULL} // 100)")
-    echo -n "Audio volume set to ${1}%."
-    audio_dev_is_mute && echo -n " (But audio device is muted.)"
+    pacmd set-${TYPE}-volume "${IDX}" $(calc "($1 * ${AT_FULL} // 100)")
+    echo -n "Audio ${TYPE} volume set to ${1}%."
+    audio_dev_is_mute "${TYPE}" "${IDX}" && echo -n " (But audio device is muted.)"
     echo
 }
 
-N_MAX_ARGS=1
-if [ "$#" -gt "${N_MAX_ARGS}" ]; then
-    error_exit "number of arguments greater ${N_MAX_ARGS}."
-elif [ -z "$1" ]; then
+if [ -z "$1" ]; then
     toggle_mute
 elif [ -z "$(echo -n $1 | sed 's/[0-9]*//g')" ]; then
     if [ "$1" -gt "${MAX_LOUDNESS}" ]; then
diff --git a/testing/copy/desktop/home/plom/.plomlib/audio_dev_is_mute b/testing/copy/desktop/home/plom/.plomlib/audio_dev_is_mute
index e28da40..d45fc53 100644
--- a/testing/copy/desktop/home/plom/.plomlib/audio_dev_is_mute
+++ b/testing/copy/desktop/home/plom/.plomlib/audio_dev_is_mute
@@ -1,3 +1,5 @@
 audio_dev_is_mute() {
-    [ "$(pactl get-sink-mute 0)" = "Mute: yes" ]
+    _TYPE="$1"
+    _IDX="$2"
+    [ "$(pactl get-${_TYPE}-mute ${_IDX})" = "Mute: yes" ]
 }
diff --git a/testing/copy/t490s/home/plom/.nonpath_bins/status.sh b/testing/copy/t490s/home/plom/.nonpath_bins/status.sh
index 2de1358..8f057b1 100755
--- a/testing/copy/t490s/home/plom/.nonpath_bins/status.sh
+++ b/testing/copy/t490s/home/plom/.nonpath_bins/status.sh
@@ -139,9 +139,12 @@ print_datetime() {
 }
 
 print_volume() {
-    print_bar_block "vol " '' 0
-    VOLUME="$(pactl get-sink-volume 0 | head -1 | sed 's/ //g' | cut -d'/' -f2)"
-    if audio_dev_is_mute; then
+    _NAME="$1"
+    _IDX="$2"
+    _TYPE="$3"
+    print_bar_block "$1 " '' 0
+    VOLUME="$(pactl get-${_TYPE}-volume "${_IDX}" | head -1 | sed 's/ //g' | cut -d'/' -f2)"
+    if $(audio_dev_is_mute "${_TYPE}" "${_IDX}"); then
         print_bar_block "<s>${VOLUME}</s>"
     else
         print_bar_block "${VOLUME}" "${COL_YELLOW}"
@@ -168,7 +171,8 @@ while true; do
     print_battery
     print_temperature
     print_datetime
-    print_volume
+    print_volume vol 0 sink
+    print_volume mic 1 source
     print_keyboard
     printf '],'
     sleep 0.1