Add flag to volctl to enable PulseAudio TCP module
This commit is contained in:
@@ -43,6 +43,9 @@ ${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}>
|
||||||
|
Set PulseAudio TCP module, possible values: on/off, 1/0, default enable.
|
||||||
|
|
||||||
${B}getv${N}, ${B}getvolume${N}
|
${B}getv${N}, ${B}getvolume${N}
|
||||||
Get volume level.
|
Get volume level.
|
||||||
|
|
||||||
@@ -71,6 +74,34 @@ while getopts ':h?' opt; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
pulseTcp()
|
||||||
|
{
|
||||||
|
if test "$1" = "off" || test "$1" = "0"; then
|
||||||
|
if pactl list modules short | grep -q module-simple-protocol-tcp; then
|
||||||
|
pactl unload-module module-simple-protocol-tcp
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
"$0" p off
|
||||||
|
|
||||||
|
device="$(pactl list sources short | head -n 1)"
|
||||||
|
source="$(echo "$device" | awk '{ print $1; }')"
|
||||||
|
format="$(echo "$device" | awk '{ print $4; }')"
|
||||||
|
channels="$(echo "$device" | awk '{ print $5 + 0; }')"
|
||||||
|
rate="$(echo "$device" | awk '{ print $6 + 0; }')"
|
||||||
|
|
||||||
|
# Load PulseAudio TCP module
|
||||||
|
pactl load-module module-simple-protocol-tcp \
|
||||||
|
rate="$rate" format="$format" channels="$channels" source="$source" \
|
||||||
|
record=true port=8000 listen=0.0.0.0 > /dev/null
|
||||||
|
|
||||||
|
# Echo connection info
|
||||||
|
ip="$(ip a show eth0 | awk '/inet / { print substr($2, 0, length($2) - 3) }')"
|
||||||
|
echo "server: $ip:8000"
|
||||||
|
echo "audio: ${rate}Hz ${channels}ch"
|
||||||
|
}
|
||||||
|
|
||||||
# Command handling
|
# Command handling
|
||||||
shift $((OPTIND - 1))
|
shift $((OPTIND - 1))
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@@ -95,6 +126,9 @@ case "$1" in
|
|||||||
n*)
|
n*)
|
||||||
pamixer --unmute
|
pamixer --unmute
|
||||||
;;
|
;;
|
||||||
|
p*)
|
||||||
|
pulseTcp "$2"
|
||||||
|
;;
|
||||||
getv*)
|
getv*)
|
||||||
pamixer --get-volume
|
pamixer --get-volume
|
||||||
;;
|
;;
|
||||||
|
|||||||
Reference in New Issue
Block a user