Skip to content

Instantly share code, notes, and snippets.

@jtrees
Forked from sebastiencs/volume.sh
Created January 28, 2021 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtrees/ddcaf90e7d543bd8df29840a13119aa9 to your computer and use it in GitHub Desktop.
Save jtrees/ddcaf90e7d543bd8df29840a13119aa9 to your computer and use it in GitHub Desktop.
Script to get volume notification with dunst http://imgur.com/a/qWgAw
#!/bin/bash
#
# Adjusts the volume and displays the change as a notification.
#
# Usage:
#
# ```sh
# $ ./volume.sh up
# $ ./volume.sh down
# $ ./volume.sh mute
# ```
#
# Dependencies:
#
# - dunstify
# - pulse audio
# - pulsemixer
function get_volume {
pulsemixer --get-volume | cut -d ' ' -f 1
}
function is_muted {
pulsemixer --get-mute
}
function send_notification {
volume=$(get_volume)
bar=$(seq -s "─" $(($volume / 5)) | sed 's/[0-9]//g')
dunstify -i audio-volume-muted-blocking -r 2593 -u normal " $bar"
}
case $1 in
up)
pulsemixer --unmute
pulsemixer --change-volume +5
send_notification
;;
down)
pulsemixer --unmute
pulsemixer --change-volume -5
send_notification
;;
mute)
pulsemixer --toggle-mute
if [[ "$(is_muted)" = "1" ]] ; then
dunstify -i audio-volume-muted -r 2593 -u normal "Mute"
else
send_notification
fi
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment