#!/bin/sh if [ -z "$WAYLAND_DISPLAY" ] then notification=dunst else notification=mako fi # Use pulseaudio backend first (pulsemixer) if command -v pulsemixer >/dev/null then _notify() { volume=$(pulsemixer --get-volume) # I only have 2 channels :) left=$(echo "$volume" | cut -d' ' -f1) right=$(echo "$volume" | cut -d' ' -f2) average=$(((left+right)/2)) notify-send -i "$HOME/.config/${notification}/speaker.png" "Volume: $average%" } case $1 in increase) pulsemixer --change-volume +5 && _notify ;; decrease) pulsemixer --change-volume -5 && _notify ;; toggle) pulsemixer --toggle-mute status=$(pulsemixer --get-mute) if [ "$status" -eq 1 ] || [ "$status" = "true" ] then notify-send -i "$HOME/.config/${notification}/mute.png" "Sound muted" else notify-send -i "$HOME/.config/${notification}/speaker.png" "Sound unmuted" fi ;; *) ;; esac # Then fallback to the ALSA one (alsamixer + amixer) else _notify_alsa() { volume=$(amixer get Master | sed -nre 's/.*\\[(.*%)\\].*/\\1/p') notify-send -i "$HOME/.config/${notification}/speaker.png" "Volume: $volume" } case $1 in increase) amixer set Master 5+ && _notify_alsa ;; decrease) amixer set Master 5- && _notify_alsa ;; toggle) amixer set Master toggle if amixer get Master | grep "off" then notify-send -i "$HOME/.config/${notification}/mute.png" "Sound muted" else notify-send -i "$HOME/.config/${notification}/speaker.png" "Sound unmuted" fi ;; *) ;; esac fi