nixos-config/home/vol.sh

24 lines
633 B
Bash

#!/usr/bin/env bash
msgTag="voldunst"
case "$1" in
mute)
pactl set-sink-mute @DEFAULT_SINK@ toggle > /dev/null
;;
*)
pactl set-sink-volume @DEFAULT_SINK@ "$1" > /dev/null
;;
esac
volume="$(pactl get-sink-volume @DEFAULT_SINK@ | head -1 | awk '{ print $5 }')"
mute="$(pactl get-sink-mute @DEFAULT_SINK@ | cut -d' ' -f2)"
if [[ $volume == "0%" || "$mute" == "yes" ]]; then
dunstify -a "changeVolume" -u low \
-h string:x-dunst-stack-tag:$msgTag "Volume muted"
else
dunstify -a "changeVolume" -u low \
-h string:x-dunst-stack-tag:$msgTag \
-h int:value:"$volume" "Volume: ${volume}"
fi