Instead of calling pactl or amixer directly, you can use this script.
The advantage is that this script checks whether the sound is muted,
and unmutes it for you when you change the volume, more closely
mimicking the behavior of most desktop environments. It also sends a
notification with the current audio status. This implementation relies
on amixer and pulseaudio, although could easily work with an alsa-only
setup if that's your thing, just by replacing the pactl commands with
amixer (or any other alsa mixer) commands.
--- /dev/null
+#!/usr/bin/env bash
+# When changing volume, if muted, unmute
+
+if [[ ${1} ]]; then
+ [[ $(amixer sget Master | tail -n 1 | grep "off") ]] &&
+ pactl set-sink-mute 0 toggle
+ pactl set-sink-volume 0 ${1}%
+else
+ pactl set-sink-mute 0 toggle
+fi
+
+notify-send "Volume" "$(amixer sget Master | tail -n 1)" -t 1000