dotfiles/bin/polybar/pulseaudio-tail.sh

57 lines
791 B
Bash
Raw Normal View History

2018-05-25 21:47:28 +00:00
#!/bin/sh
sink=0
volume_up() {
pactl set-sink-volume $sink +1%
}
volume_down() {
pactl set-sink-volume $sink -1%
}
volume_mute() {
pactl set-sink-mute $sink toggle
}
volume_print() {
2019-02-11 16:43:02 +00:00
icon=""
2018-05-25 21:47:28 +00:00
muted=$(pamixer --sink $sink --get-mute)
if [ "$muted" = true ]; then
echo "$icon --"
else
echo "$icon $(pamixer --sink $sink --get-volume)"
fi
}
listen() {
volume_print
pactl subscribe | while read -r event; do
if echo "$event" | grep -q "#$sink"; then
volume_print
fi
done
}
case "$1" in
--up)
volume_up
;;
--down)
volume_down
;;
--mute)
volume_mute
;;
--show)
show_active
;;
*)
listen
;;
esac