2020-02-08 23:43:37 +00:00
|
|
|
#!/bin/sh
|
2019-11-23 21:23:24 +00:00
|
|
|
|
2020-06-14 23:13:13 +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
|
2023-05-26 22:11:06 +00:00
|
|
|
1) setsid -w -f "$TERMINAL" -e pulsemixer; pkill -RTMIN+10 "${STATUSBAR:-dwmblocks}" ;;
|
2023-01-15 05:26:57 +00:00
|
|
|
2) wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle ;;
|
|
|
|
4) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+ ;;
|
|
|
|
5) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%- ;;
|
2020-04-09 02:01:51 +00:00
|
|
|
3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted.
|
2019-11-23 21:23:24 +00:00
|
|
|
- Middle click to mute.
|
2020-05-07 21:31:42 +00:00
|
|
|
- Scroll to change." ;;
|
2023-12-30 17:04:51 +00:00
|
|
|
6) setsid -f "$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: }"
|
2023-02-06 22:05:16 +00:00
|
|
|
|
2022-10-02 19:25:29 +00:00
|
|
|
split() {
|
|
|
|
# For ommiting the . without calling and external program.
|
|
|
|
IFS=$2
|
|
|
|
set -- $1
|
|
|
|
printf '%s' "$@"
|
|
|
|
}
|
2023-02-06 22:05:16 +00:00
|
|
|
|
|
|
|
vol="$(printf "%.0f" "$(split "$vol" ".")")"
|
2022-10-02 19:25:29 +00:00
|
|
|
|
|
|
|
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%"
|