pulse_sink: list audio devices by description

This commit is contained in:
Leonardo Eugênio 2022-11-30 22:00:19 -03:00
parent 3e56f12373
commit 4f15bf99d4

View file

@ -1,12 +1,26 @@
#!/bin/sh
output=$(printf "HDMI\nHeadphones" | wdmenu -i -p "Output:")
list_sinks() {
env LC_ALL=C pactl list sinks
}
desc=$(
list_sinks |
grep -ie "description:" |
cut -d: -f2 |
sed 's/^ //g;s/ $//g;' |
wdmenu -i -p "Output:"
)
device=$(
list_sinks |
grep -C2 "Description: $desc"|
grep Name |
cut -d: -f2 |
xargs
)
vol=$(pamixer --get-volume)
case "$output" in
HDMI)
pactl set-default-sink alsa_output.pci-0000_07_00.1.hdmi-stereo-extra1
;;
Headphones)
pactl set-default-sink alsa_output.pci-0000_09_00.4.analog-stereo
;;
esac
pactl set-default-sink "$device"
pamixer --set-volume "$vol"