From 4feafcf6200ec215bc16c48d5ecc75e394cb651f Mon Sep 17 00:00:00 2001 From: Vlad Doster Date: Sat, 9 May 2020 20:18:03 -0500 Subject: [PATCH] Update volume --- .local/bin/statusbar/volume | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/.local/bin/statusbar/volume b/.local/bin/statusbar/volume index 6224dce9..8df98c8f 100755 --- a/.local/bin/statusbar/volume +++ b/.local/bin/statusbar/volume @@ -1,23 +1,31 @@ #!/bin/sh -# Prints the current volume or 🔇 if muted. +# Prints the current volume or 🔇 if muted. Uses PulseAudio by default, +# uncomment the ALSA lines if you remove PulseAudio. case $BLOCK_BUTTON in - 1) setsid "$TERMINAL" -e alsamixer & ;; - 2) amixer sset Master toggle ;; - 4) amixer sset Master 5%+ >/dev/null 2>/dev/null ;; - 5) amixer sset Master 5%- >/dev/null 2>/dev/null ;; + # 1) setsid "$TERMINAL" -e alsamixer & ;; + # 2) amixer sset Master toggle ;; + # 4) amixer sset Master 5%+ >/dev/null 2>/dev/null ;; + # 5) amixer sset Master 5%- >/dev/null 2>/dev/null ;; + 1) setsid "$TERMINAL" -e pulsemixer & ;; + 2) pamixer -t ;; + 4) pamixer --allow-boost -i 1 ;; + 5) pamixer --allow-boost -d 1 ;; 3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted. - Middle click to mute. - Scroll to change." ;; 6) "$TERMINAL" -e "$EDITOR" "$0" ;; esac -volstat="$(amixer get Master)" +volstat="$(pactl list sinks)" +# volstat="$(amixer get Master)" # ALSA only equivalent. -echo "$volstat" | grep "\[off\]" >/dev/null && printf "🔇\\n" && exit +echo "$volstat" | grep -q "Mute: yes" && printf "🔇\\n" && exit +# echo "$volstat" | grep "\[off\]" >/dev/null && printf "🔇\\n" && exit # ALSA -vol=$(echo "$volstat" | grep -o "\[[0-9]\+%\]" | sed "s/[^0-9]*//g;1q") +vol="$(echo "$volstat" | grep '[0-9]\+%' | sed "s,.* \([0-9]\+\)%.*,\1,;1q")" +# vol=$(echo "$volstat" | grep -o "\[[0-9]\+%\]" | sed "s/[^0-9]*//g;1q") # ALSA if [ "$vol" -gt "70" ]; then icon="🔊" @@ -27,4 +35,4 @@ else icon="🔉" fi -printf " %s %s%% " "$icon" "$vol" +printf "%s %s%%\\n" "$icon" "$vol"