1
0
Fork 0
dotfiles/.local/bin/pamixer-notify

34 lines
995 B
Plaintext
Raw Normal View History

2023-02-07 17:19:53 +01:00
#!/bin/sh
2023-02-06 22:51:45 +01:00
# Arbitrary but unique message tag
msgTag="volume"
# Change the volume using alsa(might differ if you use pulseaudio)
2023-02-07 17:19:53 +01:00
pamixer "$@" >/dev/null
2023-02-06 22:51:45 +01:00
# Query amixer for the current volume and whether or not the speaker is muted
volume="$(pamixer --get-volume)"
2023-02-09 13:13:18 +01:00
[ "$volume" -gt "100" ] && highlight="#ff768e" || highlight="#7aa2f7"
2023-02-06 22:51:45 +01:00
if [ "$volume" -gt "70" ]; then
icon="audio-volume-high"
elif [ "$volume" -gt "30" ]; then
icon="audio-volume-medium"
elif [ "$volume" -gt "0" ]; then
icon="audio-volume-low"
fi
mute="$(pamixer --get-mute)"
if [ "$volume" = 0 ] || [ "$mute" = "true" ]; then
2023-02-09 13:13:18 +01:00
notify-send -a "changeVolume" -i "audio-volume-muted" -u low -h string:x-dunst-stack-tag:$msgTag "Volume muted"
2023-02-06 22:51:45 +01:00
else
2023-02-09 13:13:18 +01:00
notify-send -a "changeVolume" -i "$icon" -u low "Volume: ${volume}%"\
-h string:x-dunst-stack-tag:$msgTag \
-h int:value:$volume \
-h string:hlcolor:$highlight
2023-02-06 22:51:45 +01:00
fi
# Play the volume changed sound
canberra-gtk-play -i audio-volume-change -d "changeVolume"