#!/bin/bash

# amount=$(echo "$1" | cut -d " " -f 2)
send_notification() {
	# dunstify -r 13123 -h "int:value:$1" "$2 Volume ($1%)" -t 2000
	dunstify -r 13123 "$2 Volume $1%" -t 1750
}

get_icon() {
	if [ "$curr" -gt "50" ]; then
		icon="🔊"
	elif [ "$curr" -eq "0" ]; then
		icon="🔇"
	elif [ "$curr" -lt "25" ]; then
		icon="🔈"
	else
		icon="🔉"
	fi
}

pactl set-sink-mute @DEFAULT_SINK@ toggle;

if [ "$(pamixer --get-mute)" == "false" ]; then
	curr=$(pamixer --get-volume)
	get_icon $icon
	send_notification $curr $icon
else
	send_notification "0" "🔇"
fi

kill -35 $(pidof dwmblocks)

# min=$((0 + $amount))
# max=$((100 - $amount))

# (($curr<=$max)) && $(pactl set-sink-volume @DEFAULT_SINK@ +$amount%)

# [ $curr -ne $min ] && [ $curr -ne $max ] && curr=$(($curr + $amount))

# send_notification $curr $icon
