-
-
Save jtrees/ddcaf90e7d543bd8df29840a13119aa9 to your computer and use it in GitHub Desktop.
Script to get volume notification with dunst http://imgur.com/a/qWgAw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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