48 lines
1.2 KiB
Bash
Executable File
48 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# You can call this script like this:
|
|
# $./volume.sh up
|
|
# $./volume.sh down
|
|
# $./volume.sh mute
|
|
|
|
function get_volume {
|
|
pulseaudio-control output | awk '{ print $1 }'
|
|
}
|
|
|
|
function is_mute {
|
|
if [[ $(pulseaudio-control output) == *"%{F"* ]]; then echo "a"; fi
|
|
}
|
|
|
|
function send_notification {
|
|
volume=`get_volume`
|
|
# 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 [[ $(dunstctl is-paused) == "false" ]]; then dunstify -i audio-on -r 2593 -u low "$volume $bar" -a Volume; 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%)
|
|
#amixer -D pulse sset Master 5%+ > /dev/null
|
|
send_notification
|
|
;;
|
|
down)
|
|
#amixer -D pulse set Master on > /dev/null
|
|
#amixer -D pulse sset Master 5%- > /dev/null
|
|
send_notification
|
|
;;
|
|
mute)
|
|
# Toggle mute
|
|
#amixer -D pulse set Master 1+ toggle > /dev/null
|
|
if is_mute ; then
|
|
if [[ $(dunstctl is-paused) == "false" ]]; then dunstify -i audio-volume-muted -r 2593 -u low "Muto" -a Volume; fi
|
|
else
|
|
send_notification
|
|
fi
|
|
;;
|
|
esac
|