2020-05-09 23:50:50 -05:00

31 lines
695 B
Bash
Executable File

#!/bin/sh
# Prints the current volume or 🔇 if muted.
case $BLOCK_BUTTON in
1) setsid "$TERMINAL" -e pulsemixer & ;;
2) pamixer -t ;;
4) pamixer --allow-boost -i 10 ;;
5) pamixer --allow-boost -d 10 ;;
3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted.
- Middle click to mute.
- Scroll to change." ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
volstat="$(pactl list sinks)"
echo "$volstat" | grep -q "Mute: yes" && printf "🔇\\n" && exit
vol="$(echo "$volstat" | grep '[0-9]\+%' | sed "s,.* \([0-9]\+\)%.*,\1,;1q")"
if [ "$vol" -gt "70" ]; then
icon="🔊"
elif [ "$vol" -lt "30" ]; then
icon="🔈"
else
icon="🔉"
fi
printf " %s %s%% " "$icon" "$vol"