#!/bin/bash # You can call this script like this: # $./volume.sh up # $./volume.sh down # $./volume.sh mute # Original from: https://gist.github.com/sebastiencs/5d7227f388d93374cebdf72e783fbd6a function get_volume { pamixer --get-volume } function is_mute { pamixer --get-volume-human | grep muted > /dev/null } function send_notification { volume=`get_volume` icon_quiet="/usr/share/icons/Adwaita/48x48/status/audio-volume-low-symbolic.symbolic.png" icon_loud="/usr/share/icons/Adwaita/48x48/status/audio-volume-high-symbolic.symbolic.png" icon_medium="/usr/share/icons/Adwaita/48x48/status/audio-volume-medium-symbolic.symbolic.png" icon_muted="/usr/share/icons/Adwaita/48x48/status/audio-volume-muted-symbolic.symbolic.png" # Make the bar with the special character ─ (it's not dash -) # https://en.wikipedia.org/wiki/Box-drawing_character bar=$(seq -s "─" $(($volume / 5)) | sed 's/[0-9]//g') # Send the notification # if [ "$volume" == "muted" ]; then icon="/usr/share/icons/Adwaita/48x48/status/audio-volume-muted-symbolic.symbolic.png" #dunstify -i "$icon" -t 2000 --replace 2593 -u normal " $bar" dunstify "$volume"" ""$bar" -i "/usr/share/icons/Adwaita/48x48/status/audio-volume-muted-symbolic.symbolic.png" -t 2000 -h int:value:"$volume" -h string:synchronous:"$bar" --replace=555 #else # if [ "$volume" -lt "10" ]; then # icon="/usr/share/icons/Adwaita/48x48/status/audio-volume-low-symbolic.symbolic.png" # else # if [ "$volume" -lt "30" ]; then # icon="/usr/share/icons/Adwaita/48x48/status/audio-volume-medium-symbolic.symbolic.png" # else # if [ "$volume" -lt "70" ]; then # icon="/usr/share/icons/Adwaita/48x48/status/audio-volume-high-symbolic.symbolic.png" # fi # fi # fi #fi } case $1 in up) # Set the volume on (if it was muted) #amixer -D pulse set Master on > /dev/null # Up the volume (+ 5%) pamixer -i 5 canberra-gtk-play -i audio-volume-change -d "changeVolume" send_notification ;; down) #amixer -D pulse set Master on > /dev/null pamixer -d 5 canberra-gtk-play -i audio-volume-change -d "changeVolume" send_notification ;; mute) # Toggle mute pamixer -t if is_mute ; then dunstify -i audio-volume-muted -t 2000 -r 2593 -u normal "Mute" else canberra-gtk-play -i audio-volume-change -d "changeVolume" send_notification fi ;; esac