#!/bin/sh

dir="/usr/local/bin/icons"

cur_vol=$(awk -F"[][]" '/Left:/ { print $2 }' <(amixer sget Master) | sed 's/%//g')
MUTE=$(pacmd list-sinks | awk '/muted/ { print $2 }' | head -1)
affirmative="yes"
negative="no"

vol_quiet=33
vol_loud=66

if [ "$MUTE" = "$affirmative" ]; then
        dunstify -a "Speakers" \
        "Speakers" \
        "Speakers are muted" \
        -r 100 \
        -i "$dir"/volume-x.svg
elif [ "$MUTE" = "$negative" ]; then
        if [ "$cur_vol" -le "$vol_quiet" ]; then
            dunstify -a "Speakers" \
            "Speakers" \
            "Speakers are unmuted" \
            -r 100 \
            -i "$dir"/volume.svg
        fi
        if [ "$cur_vol" -gt "$vol_quiet" ] && [ "$cur_vol" -le "$vol_loud" ]; then
            dunstify -a "Speakers" \
            "Speakers" \
            "Speakers are unmuted" \
            -r 100 \
            -i "$dir"/volume-1.svg
        fi
        if [ "$cur_vol" -gt "$vol_loud" ]; then
            dunstify -a "Speakers" \
            "Speakers" \
            "Speakers are unmuted" \
            -r 100 \
            -i "$dir"/volume-2.svg
        fi

    fi
echo "$MUTE"