Created
August 11, 2021 12:24
-
-
Save ghostface/6c0b1c289d330dade5703da290b07663 to your computer and use it in GitHub Desktop.
Wrapper for volume control with dunst notification
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 | |
# Arbitrary but unique message id | |
msgId="991049" | |
# Change the volume using alsa(might differ if you use pulseaudio) | |
#amixer -c 0 set Master "$@" > /dev/null | |
if [[ $1 == "up" ]]; then | |
pamixer -i 5 | |
else | |
pamixer -d 5 | |
fi | |
# Query amixer for the current volume and whether or not the speaker is muted | |
#volume="$(amixer -c 0 get Master | tail -1 | awk '{print $4}' | sed 's/[^0-9]*//g')" | |
#volume="$(pulseaudio-ctl full-status | sed -e 's,^\([0-9][0-9]*\)[^0-9].*,\1,')" | |
volume="$(pamixer --get-volume)" | |
#mute="$(amixer -c 0 get Master | tail -1 | awk '{print $6}' | sed 's/[^a-z]*//g')" | |
mute="$(pamixer --get-mute)" | |
if [[ $volume == 0 || "$mute" == "true" ]]; then | |
# Show the sound muted notification | |
dunstify -a "changeVolume" -u low -i audio-volume-muted -r "$msgId" "Volume muted" | |
else | |
# Show the volume notification | |
dunstify -a "changeVolume" -u low -i audio-volume-high -r "$msgId" \ | |
-h int:value:"$volume" "Volume: ${volume}%" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment