#!/bin/sh

# Prints the current volume or 🔇 if muted.

# case $BLOCK_BUTTON in
# 	1) setsid -f "$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

# [ $(pamixer --get-mute) = true ] && echo "🔇  ^c#FF2a2a^0%^d^" && exit
# [ $(pamixer --get-mute) = true ] && echo "🔇  0%" && exit

# [ $(awk -F "[][]" '/Left:/ { print $4 }' <(amixer sget Master)) == "off" ] && echo "🔇  0%" && exit

vol="$(pamixer --get-volume)"
# vol="$(awk -F "[][]" '/Left:/ { $2 - substr($2, 2, lenghth($2) - 1); print $2 }' <(amixer sget Master))"

[ $(pamixer --get-mute) = true ] && printf "🔇%3d%s" $vol "%" && exit

if [ "$vol" -gt "49" ]; then
	icon="🔊"
elif [ "$vol" -eq "0" ]; then
	icon="🔇"
elif [ "$vol" -lt "25" ]; then
	icon="🔈"
else
	icon="🔉"
fi

printf "%s%3d%s" "$icon" "$vol" "%"
