use pamixer again

This commit is contained in:
Amy 2022-10-04 20:11:56 +11:00 committed by GitHub
parent 87ab89cf18
commit 89cf986de0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,26 +13,15 @@ case $BLOCK_BUTTON in
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
[ "$(pamixer --get-mute)" = true ] && echo "m" && exit
# If muted, print 🔇 and exit.
[ "$vol" != "${vol%\[MUTED\]}" ] && echo 🔇 && exit
vol="${vol#Volume: }"
split() {
# For ommiting the . without calling and external program.
IFS=$2
set -- $1
printf '%s' "$@"
}
vol="$(split "$vol" ".")"
vol="${vol##0}"
vol="$(pamixer --get-volume)"
case 1 in
$((vol >= 70)) ) icon="🔊" ;;
$((vol >= 30)) ) icon="🔉" ;;
$((vol >= 1)) ) icon="🔈" ;;
* ) echo 🔇 && exit ;;
$((vol >= 70)) ) icon="🔊" ;;
$((vol >= 30)) ) icon="🔉" ;;
$((vol >= 1)) ) icon="🔈" ;;
* ) echo m && exit ;;
esac
echo "$icon$vol%"