voidrice/.local/bin/statusbar/sb-volume

39 lines
843 B
Text
Raw Normal View History

#!/bin/sh
2019-11-23 21:23:24 +00:00
# Prints the current volume or 🔇 if muted.
2020-04-09 21:03:51 +00:00
2019-11-23 21:23:24 +00:00
case $BLOCK_BUTTON in
1) setsid -f "$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
2022-10-02 19:25:29 +00:00
vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
2019-11-23 21:23:24 +00:00
2022-10-02 19:25:29 +00:00
# If muted, print 🔇 and exit.
[ "$vol" != "${vol%\[MUTED\]}" ] && echo 🔇 && exit
2019-11-23 21:23:24 +00:00
2022-10-02 19:25:29 +00:00
vol="${vol#Volume: }"
split() {
# For ommiting the . without calling and external program.
IFS=$2
set -- $1
printf '%s' "$@"
}
vol="$(split "$vol" ".")"
vol="${vol##0}"
case 1 in
$((vol >= 70)) ) icon="🔊" ;;
$((vol >= 30)) ) icon="🔉" ;;
$((vol >= 1)) ) icon="🔈" ;;
* ) echo 🔇 && exit ;;
esac
2019-11-23 21:23:24 +00:00
2021-10-18 12:50:15 +00:00
echo "$icon$vol%"