mirror of
https://github.com/lordmathis/dotfiles.git
synced 2025-11-06 01:34:22 +00:00
Add scripts
This commit is contained in:
72
bin/pulseaudio-tail.sh
Executable file
72
bin/pulseaudio-tail.sh
Executable file
@@ -0,0 +1,72 @@
|
||||
#!/bin/sh
|
||||
|
||||
sink=0
|
||||
|
||||
show_active() {
|
||||
if pacmd list-sinks | grep active | head -n 1 | grep -q speaker; then
|
||||
echo "speaker"
|
||||
elif pacmd list-sinks | grep active | head -n 1 | grep headphones; then
|
||||
echo "headphones"
|
||||
else
|
||||
echo "hdmi"
|
||||
fi
|
||||
}
|
||||
|
||||
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() {
|
||||
if pacmd list-sinks | grep active | head -n 1 | grep -q speaker; then
|
||||
icon=""
|
||||
elif pacmd list-sinks | grep active | head -n 1 | grep headphones; then
|
||||
icon=""
|
||||
else
|
||||
icon=""
|
||||
fi
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user