#!/bin/sh

pamixer "$@" >/dev/null

msgTag="volume" # Arbitrary but unique message tag
volume="$(pamixer --get-volume)"
mute="$(pamixer --get-mute)"

[ "$volume" -gt "100" ] &&
    highlight="#ff768e" ||
    highlight="#7aa2f7"

if [ "$mute" = "true" ]; then
    icon="audio-volume-muted"
elif [ "$volume" -gt "70" ]; then
    icon="audio-volume-high"
elif [ "$volume" -gt "30" ]; then
    icon="audio-volume-medium"
elif [ "$volume" -ge "0" ]; then
    icon="audio-volume-low"
fi

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