From 6d4e2bc2478e1c819ae6056b9e4d32d421b7dcf4 Mon Sep 17 00:00:00 2001 From: Johannes Kamprad Date: Fri, 20 May 2022 15:47:47 +0200 Subject: [PATCH] Update volume update script and add source links --- .config/i3/scripts/volume | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.config/i3/scripts/volume b/.config/i3/scripts/volume index 4f0a2c2..39618e1 100644 --- a/.config/i3/scripts/volume +++ b/.config/i3/scripts/volume @@ -15,6 +15,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +# original source: https://github.com/vivien/i3blocks-contrib/tree/master/volume +# check the readme: https://github.com/vivien/i3blocks-contrib/blob/master/volume/README.md #------------------------------------------------------------------------ # The second parameter overrides the mixer selection @@ -23,7 +25,7 @@ # For ALSA users, you may use "default" for your primary card # or you may use hw:# where # is the number of the card desired if [[ -z "$MIXER" ]] ; then - MIXER="pulse" + MIXER="default" if command -v pulseaudio >/dev/null 2>&1 && pulseaudio --check ; then # pulseaudio is running, but not all installations use "pulse" if amixer -D pulse info >/dev/null 2>&1 ; then @@ -50,15 +52,23 @@ if [[ -z "$STEP" ]] ; then STEP="${1:-5%}" fi +# AMIXER(1): +# "Use the mapped volume for evaluating the percentage representation like alsamixer, to be +# more natural for human ear." +NATURAL_MAPPING=${NATURAL_MAPPING:-0} +if [[ "$NATURAL_MAPPING" != "0" ]] ; then + AMIXER_PARAMS="-M" +fi + #------------------------------------------------------------------------ capability() { # Return "Capture" if the device is a capture device - amixer -D $MIXER get $SCONTROL | + amixer $AMIXER_PARAMS -D $MIXER get $SCONTROL | sed -n "s/ Capabilities:.*cvolume.*/Capture/p" } volume() { - amixer -D $MIXER get $SCONTROL $(capability) + amixer $AMIXER_PARAMS -D $MIXER get $SCONTROL $(capability) } format() { @@ -75,9 +85,9 @@ format() { #------------------------------------------------------------------------ case $BLOCK_BUTTON in - 3) amixer -q -D $MIXER sset $SCONTROL $(capability) toggle ;; # right click, mute/unmute - 4) amixer -q -D $MIXER sset $SCONTROL $(capability) ${STEP}+ unmute ;; # scroll up, increase - 5) amixer -q -D $MIXER sset $SCONTROL $(capability) ${STEP}- unmute ;; # scroll down, decrease + 3) amixer $AMIXER_PARAMS -q -D $MIXER sset $SCONTROL $(capability) toggle ;; # right click, mute/unmute + 4) amixer $AMIXER_PARAMS -q -D $MIXER sset $SCONTROL $(capability) ${STEP}+ unmute ;; # scroll up, increase + 5) amixer $AMIXER_PARAMS -q -D $MIXER sset $SCONTROL $(capability) ${STEP}- unmute ;; # scroll down, decrease esac volume | format