voidrice/.local/bin/statusbar/volume

39 lines
1.2 KiB
Text
Raw Normal View History

#!/bin/sh
2019-11-23 21:23:24 +00:00
2020-04-09 21:03:51 +00:00
# Prints the current volume or 🔇 if muted. Uses PulseAudio by default,
# uncomment the ALSA lines if you remove PulseAudio.
2019-11-23 21:23:24 +00:00
case $BLOCK_BUTTON in
2020-04-09 21:03:51 +00:00
# 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 & ;;
2020-04-15 00:37:22 +00:00
2) pamixer -t ;;
4) pamixer --allow-boost -i 1 ;;
5) pamixer --allow-boost -d 1 ;;
3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted.
2019-11-23 21:23:24 +00:00
- Middle click to mute.
- Scroll to change." ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
2019-11-23 21:23:24 +00:00
esac
2020-04-09 21:03:51 +00:00
volstat="$(pactl list sinks)"
# volstat="$(amixer get Master)" # ALSA only equivalent.
2019-11-23 21:23:24 +00:00
2020-04-09 21:03:51 +00:00
echo "$volstat" | grep -q "Mute: yes" && printf "🔇\\n" && exit
# echo "$volstat" | grep "\[off\]" >/dev/null && printf "🔇\\n" && exit # ALSA
2019-11-24 04:37:40 +00:00
2020-04-15 01:45:09 +00:00
vol="$(echo "$volstat" | grep '[0-9]\+%' | sed "s,.* \([0-9]\+\)%.*,\1,;1q")"
2020-04-09 21:03:51 +00:00
# vol=$(echo "$volstat" | grep -o "\[[0-9]\+%\]" | sed "s/[^0-9]*//g;1q") # ALSA
2019-11-23 21:23:24 +00:00
if [ "$vol" -gt "70" ]; then
icon="🔊"
elif [ "$vol" -lt "30" ]; then
icon="🔈"
else
icon="🔉"
fi
2020-05-25 21:06:24 +00:00
printf "%s%s%%\\n" "$icon" "$vol"