#!/bin/sh
# Thank you Arch Wiki: https://wiki.archlinux.org/index.php/Dunst#Dunstify
# Arbitrary but unique message id
msgId="509842"
# Set the volume based on args given
if [ "$1" = "up" ]; then
sndioctl output.level=+0.05
elif [ "$1" = "down" ]; then
sndioctl output.level=-0.05
elif [ "$(sndioctl output.mute | cut -d= -f2)" -eq 0 ]; then
sndioctl output.mute=1
muted=1
else
sndioctl output.mute=0
fi
volume=$(sndioctl output.level | cut -d= -f2)
if [ "$volume" = "1.000" ]; then
volume=100
else
volume=$(echo "$volume" | cut -d. -f2)
volume=$(($volume/10))
echo "$volume"
fi
if [ "$muted" -eq 1 ]; then
# Show the sound muted notification
dunstify -a "changeVolume" -u low -r "$msgId" "Volume muted"
else
# Show the volume notification
dunstify -a "changeVolume" -u low -r "$msgId" "Volume: $volume%"
fi
exit 0