diff options
Diffstat (limited to 'sys/change-audio')
-rwxr-xr-x | sys/change-audio | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sys/change-audio b/sys/change-audio new file mode 100755 index 0000000..2dafe73 --- /dev/null +++ b/sys/change-audio @@ -0,0 +1,21 @@ +#!/bin/bash +# change-audio +# Shamelessly copied from the Arch Linux wiki. + +# Arbitrary but unique message tag +msgTag="myvolume" + +# Change the volume using alsa(might differ if you use pulseaudio) +amixer -M -c 0 set Master "$@" > /dev/null + +# Query amixer for the current volume and whether or not the speaker is muted +volume="$(amixer -M -c 0 get Master | tail -1 | awk '{print $4}' | sed 's/[^0-9]*//g')" +mute="$(amixer -M -c 0 get Master | tail -1 | awk '{print $6}' | sed 's/[^a-z]*//g')" +if [[ $volume == 0 || "$mute" == "off" ]]; then + # Show the sound muted notification + dunstify -a "changeVolume" -u low -i audio-volume-muted -h string:x-dunst-stack-tag:$msgTag "Volume muted" +else + # Show the volume notification + dunstify -a "changeVolume" -u low -i audio-volume-high -h string:x-dunst-stack-tag:$msgTag \ + -h int:value:"$volume" "Volume: ${volume}%" +fi |