Scripts: Add output device selection to PulseAudio TCP module
This commit is contained in:
+13
-4
@@ -43,7 +43,7 @@ ${B}COMMANDS${N}
|
||||
${B}u${N}, ${B}unmute${N}
|
||||
Unmute volume.
|
||||
|
||||
${B}p${N} <${U}STATE${N}>, ${B}pulsetcp${N} <${U}STATE${N}>
|
||||
${B}p${N} <${U}STATE${N}> <${U}DEVICE${N}>, ${B}pulsetcp${N} <${U}STATE${N}> <${U}DEVICE${N}>
|
||||
Set PulseAudio TCP module, possible values: on/off, 1/0, default enable.
|
||||
|
||||
${B}getv${N}, ${B}getvolume${N}
|
||||
@@ -76,7 +76,7 @@ done
|
||||
|
||||
pulseTcp()
|
||||
{
|
||||
if test "$1" = "off" || test "$1" = "0"; then
|
||||
if test "$2" = "off" || test "$2" = "0"; then
|
||||
if pactl list modules short | grep -q module-simple-protocol-tcp; then
|
||||
pactl unload-module module-simple-protocol-tcp
|
||||
fi
|
||||
@@ -85,7 +85,16 @@ pulseTcp()
|
||||
|
||||
"$0" p off
|
||||
|
||||
device="$(pactl list sources short | head -n 1)"
|
||||
# Select audio output device
|
||||
devices="$(pactl list sources short | awk '/alsa_output.*RUNNING/ { print }' | sort -k 2)"
|
||||
select="$3"
|
||||
if [ -z "$select" ]; then
|
||||
echo "$devices" | sed -nE '=;s/.*alsa_output\.(.*)\.monitor.*/\1/p;' | sed 'N;s/\n/) /'
|
||||
printf "Enter device to stream: "
|
||||
read -r select
|
||||
fi
|
||||
|
||||
device="$(echo "$devices" | sed -n "${select}p")"
|
||||
source="$(echo "$device" | awk '{ print $1; }')"
|
||||
format="$(echo "$device" | awk '{ print $4; }')"
|
||||
channels="$(echo "$device" | awk '{ print $5 + 0; }')"
|
||||
@@ -127,7 +136,7 @@ case "$1" in
|
||||
pamixer --unmute
|
||||
;;
|
||||
p*)
|
||||
pulseTcp "$2"
|
||||
pulseTcp "$@"
|
||||
;;
|
||||
getv*)
|
||||
pamixer --get-volume
|
||||
|
||||
Reference in New Issue
Block a user