#!/bin/sh # Arbitrary but unique message tag msgTag="volume" # Change the volume using alsa(might differ if you use pulseaudio) pamixer "$@" >/dev/null # Query amixer for the current volume and whether or not the speaker is muted volume="$(pamixer --get-volume)" [ "$volume" -gt "100" ] && highlight="#ff768e" || highlight="#7aa2f7" if [ "$volume" -gt "70" ]; then icon="audio-volume-high" elif [ "$volume" -gt "30" ]; then icon="audio-volume-medium" elif [ "$volume" -gt "0" ]; then icon="audio-volume-low" fi mute="$(pamixer --get-mute)" if [ "$volume" = 0 ] || [ "$mute" = "true" ]; then notify-send -a "changeVolume" -i "audio-volume-muted" -u low -h string:x-dunst-stack-tag:$msgTag "Volume muted" else notify-send -a "changeVolume" -i "$icon" -u low "Volume: ${volume}%"\ -h string:x-dunst-stack-tag:$msgTag \ -h int:value:$volume \ -h string:hlcolor:$highlight fi # Play the volume changed sound canberra-gtk-play -i audio-volume-change -d "changeVolume"