Browse Source

Scripts: Add output device selection to PulseAudio TCP module

master
Riyyi 3 years ago
parent
commit
8835b90bc3
  1. 17
      .local/bin/volctl

17
.local/bin/volctl

@ -43,7 +43,7 @@ ${B}COMMANDS${N}
${B}u${N}, ${B}unmute${N} ${B}u${N}, ${B}unmute${N}
Unmute volume. 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. Set PulseAudio TCP module, possible values: on/off, 1/0, default enable.
${B}getv${N}, ${B}getvolume${N} ${B}getv${N}, ${B}getvolume${N}
@ -76,7 +76,7 @@ done
pulseTcp() 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 if pactl list modules short | grep -q module-simple-protocol-tcp; then
pactl unload-module module-simple-protocol-tcp pactl unload-module module-simple-protocol-tcp
fi fi
@ -85,7 +85,16 @@ pulseTcp()
"$0" p off "$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; }')" source="$(echo "$device" | awk '{ print $1; }')"
format="$(echo "$device" | awk '{ print $4; }')" format="$(echo "$device" | awk '{ print $4; }')"
channels="$(echo "$device" | awk '{ print $5 + 0; }')" channels="$(echo "$device" | awk '{ print $5 + 0; }')"
@ -127,7 +136,7 @@ case "$1" in
pamixer --unmute pamixer --unmute
;; ;;
p*) p*)
pulseTcp "$2" pulseTcp "$@"
;; ;;
getv*) getv*)
pamixer --get-volume pamixer --get-volume

Loading…
Cancel
Save