#!/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)" if [ "$volume" -gt "100" ]; then urgency="critical" else urgency="low" fi 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 $urgency -h string:x-dunst-stack-tag:$msgTag "Volume muted" else notify-send -a "changeVolume" -i "$icon" -u $urgency -h string:x-dunst-stack-tag:$msgTag \ -h int:value:"$volume" "Volume: ${volume}%" fi # Play the volume changed sound canberra-gtk-play -i audio-volume-change -d "changeVolume"