#!/usr/bin/env bash
# AUTHOR: Daesorin
# CREATED: 2026-08-04 05:01 +0100

set -euo pipefail

if [ "$1" = "toggle" ]; then
    pamixer -t
elif [[ "$1" == +* ]]; then
    val="${1#+}"
    pamixer -i "${val%\%}"
elif [[ "$1" == -* ]]; then
    val="${1#-}"
    pamixer -d "${val%\%}"
fi

volume=$(pamixer --get-volume)
muted=$(pamixer --get-mute)

if [ "$muted" = "true" ]; then
    notify-send -h string:x-canonical-private-synchronous:volume -u low "Volume: Muted"
else
    notify-send -h string:x-canonical-private-synchronous:volume -u low "Volume: ${volume}%"
fi
