pulseaudio-tail: add default sink
This commit is contained in:
parent
fd468df9e9
commit
2a3c95949f
@ -1,34 +1,42 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
sink=0
|
update_sink() {
|
||||||
|
sink=$(pacmd list-sinks | sed -n '/\* index:/ s/.*: //p')
|
||||||
|
}
|
||||||
|
|
||||||
volume_up() {
|
volume_up() {
|
||||||
pactl set-sink-volume $sink +1%
|
update_sink
|
||||||
|
pactl set-sink-volume "$sink" +1%
|
||||||
}
|
}
|
||||||
|
|
||||||
volume_down() {
|
volume_down() {
|
||||||
pactl set-sink-volume $sink -1%
|
update_sink
|
||||||
|
pactl set-sink-volume "$sink" -1%
|
||||||
}
|
}
|
||||||
|
|
||||||
volume_mute() {
|
volume_mute() {
|
||||||
pactl set-sink-mute $sink toggle
|
update_sink
|
||||||
|
pactl set-sink-mute "$sink" toggle
|
||||||
}
|
}
|
||||||
|
|
||||||
volume_print() {
|
volume_print() {
|
||||||
if pacmd list-sinks | grep active | head -n 1 | grep -q speaker; then
|
update_sink
|
||||||
|
|
||||||
|
active_port=$(pacmd list-sinks | sed -n "/index: $sink/,/index:/p" | grep active)
|
||||||
|
if echo "$active_port" | grep -q speaker; then
|
||||||
icon="#1"
|
icon="#1"
|
||||||
elif pacmd list-sinks | grep active | head -n 1 | grep -q headphones; then
|
elif echo "$active_port" | grep -q headphones; then
|
||||||
icon="#2"
|
icon="#2"
|
||||||
else
|
else
|
||||||
icon="#3"
|
icon="#3"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
muted=$(pamixer --sink $sink --get-mute)
|
muted=$(pamixer --sink "$sink" --get-mute)
|
||||||
|
|
||||||
if [ "$muted" = true ]; then
|
if [ "$muted" = true ]; then
|
||||||
echo "$icon --"
|
echo "$icon --"
|
||||||
else
|
else
|
||||||
echo "$icon $(pamixer --sink $sink --get-volume)"
|
echo "$icon $(pamixer --sink "$sink" --get-volume)"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,7 +44,7 @@ listen() {
|
|||||||
volume_print
|
volume_print
|
||||||
|
|
||||||
pactl subscribe | while read -r event; do
|
pactl subscribe | while read -r event; do
|
||||||
if echo "$event" | grep -q "#$sink"; then
|
if echo "$event" | grep -qv "Client"; then
|
||||||
volume_print
|
volume_print
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user