#!/bin/sh

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

cur_vol=$(pactl list sinks | grep '^[[:space:]]Volume:' | \
    head -n $(( SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,')
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 "Mute" \
        "Mute" \
        "Sink is now muted" \
        -r 100 \
        -i "$dir"/volume-x.svg
elif [ "$MUTE" = "$negative" ]; then
        if [ "$cur_vol" -le "$vol_quiet" ]; then
            dunstify -a "Mute" \
            "Mute" \
            "Sink is now unmuted" \
            -r 100 \
            -i "$dir"/volume.svg
        fi
        if [ "$cur_vol" -gt "$vol_quiet" ] && [ "$cur_vol" -le "$vol_loud" ]; then
            dunstify -a "Mute" \
            "Mute" \
            "Sink is now unmuted" \
            -r 100 \
            -i "$dir"/volume-1.svg
        fi
        if [ "$cur_vol" -gt "$vol_loud" ]; then
            dunstify -a "Mute" \
            "Mute" \
            "Sink is now unmuted" \
            -r 100 \
            -i "$dir"/volume-2.svg
        fi

    fi
echo "$MUTE"