Compare commits

..

No commits in common. "f1245bc1b5ffa0f5f8e99cbe80d1b61bf0dabc17" and "18ce390cc66c093a2d23dc49f7b7f03bcf441bb6" have entirely different histories.

4 changed files with 29 additions and 35834 deletions

View File

@ -1,16 +1,6 @@
#!/bin/sh #!/bin/sh
# PulseAudio script to categorise audio streams # Awful script I made to bridge calls from two services while also piping in audio
#
# - playing music while recording a call
# - piping sound files into a call via virtual mic
#
# Use the -b switch for bridging
# - connect calls from different applications
# Important settings
# Your real mic (pactl list short sources) # Your real mic (pactl list short sources)
mic="alsa_input.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.mono-fallback" mic="alsa_input.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.mono-fallback"
@ -18,76 +8,55 @@ mic="alsa_input.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.mono-fallback"
# Output sound to this sink (pactl list short sinks) # Output sound to this sink (pactl list short sinks)
out="alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo" out="alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo"
# Name of the virtual mic output (combined mic and shared media)
# Naming settings
# Virtual mic for both voice and media
virt_mic="virtual_mic" virt_mic="virtual_mic"
virt_mic_desc="Virtual\ mic" virt_mic_desc="Virtual\ mic"
# Input for media to pipe to call # Name of the media input sink
media_in="media_in" media_in="media_in"
media_in_desc="Media\ input" media_in_desc="Media\ input"
# Virtual mic for call # Name of the sink whose monitor will be used as the mic for the first call
c1_in="c1_in" c1_in="c1_in"
c1_in_desc="Call\ input" c1_in_desc="C1\ input"
# Output of call # Name of the sink where the first call will be output
c1_out="c1_out" c1_out="c1_out"
c1_out_desc="Call\ output" c1_out_desc="C1\ output"
# Virtual mic for bridged call # Name of the sink whose monitor will be used as the mic for the second call
c2_in="c2_in" c2_in="c2_in"
c2_in_desc="C2\ input" c2_in_desc="C2\ input"
# Output of bridged call # Name of the sink where the second call will be output
c2_out="c2_out" c2_out="c2_out"
c2_out_desc="C2\ output" c2_out_desc="C2\ output"
# Create all the sinks
pactl load-module module-null-sink sink_name="$media_in" sink_properties=device.description="'$media_in_desc'"
MODE="normal" pactl load-module module-null-sink sink_name="$virt_mic" sink_properties=device.description="'$virt_mic_desc'"
while getopts "b" o; do
case "${o}" in
b) MODE="bridge" ;;
esac
done
# Set up call input/output
# Create sinks
pactl load-module module-null-sink sink_name="$c1_out" sink_properties=device.description="'$c1_out_desc'" pactl load-module module-null-sink sink_name="$c1_out" sink_properties=device.description="'$c1_out_desc'"
pactl load-module module-null-sink sink_name="$c1_in" sink_properties=device.description="'$c1_in_desc'" pactl load-module module-null-sink sink_name="$c1_in" sink_properties=device.description="'$c1_in_desc'"
# Output to real speakers pactl load-module module-null-sink sink_name="$c2_out" sink_properties=device.description="'$c2_out_desc'"
pactl load-module module-loopback source="$c1_out".monitor sink="$out" pactl load-module module-null-sink sink_name="$c2_in" sink_properties=device.description="'$c2_in_desc'"
# Set up media input # Make connections between all sinks
# Create sink
pactl load-module module-null-sink sink_name="$media_in" sink_properties=device.description="'$media_in_desc'" # Loop back real mic to the virtual mic
# Output to real speakers pactl load-module module-loopback source="$mic" sink="$virt_mic"
# Loop back media input to virtual mic
pactl load-module module-loopback source="$media_in".monitor sink="$virt_mic"
# Loop back media input to regular audio output
pactl load-module module-loopback source="$media_in".monitor sink="$out" pactl load-module module-loopback source="$media_in".monitor sink="$out"
# Set up virtual mic # Loop combined output to both calls' inputs
# Create sink
pactl load-module module-null-sink sink_name="$virt_mic" sink_properties=device.description="'$virt_mic_desc'"
# Loop in real mic
pactl load-module module-loopback source="$mic" sink="$virt_mic"
# Loop in media input
pactl load-module module-loopback source="$media_in".monitor sink="$virt_mic"
# Output to call input
pactl load-module module-loopback source="$virt_mic".monitor sink="$c1_in" pactl load-module module-loopback source="$virt_mic".monitor sink="$c1_in"
pactl load-module module-loopback source="$virt_mic".monitor sink="$c2_in"
# Bridging # Loop the calls' outputs to each other's inputs and also local output
if [ $MODE = "bridge" ]; then pactl load-module module-loopback source="$c1_out".monitor sink="$out"
# Create bridged call input/output sinks pactl load-module module-loopback source="$c1_out".monitor sink="$c2_in"
pactl load-module module-null-sink sink_name="$c2_out" sink_properties=device.description="'$c2_out_desc'" pactl load-module module-loopback source="$c2_out".monitor sink="$out"
pactl load-module module-null-sink sink_name="$c2_in" sink_properties=device.description="'$c2_in_desc'" pactl load-module module-loopback source="$c2_out".monitor sink="$c1_in"
# Loop in virtual mic
pactl load-module module-loopback source="$virt_mic".monitor sink="$c2_in"
# Output to real speakers
pactl load-module module-loopback source="$c2_out".monitor sink="$out"
# Connect calls into each other
pactl load-module module-loopback source="$c1_out".monitor sink="$c2_in"
pactl load-module module-loopback source="$c2_out".monitor sink="$c1_in"
fi

View File

@ -1,19 +0,0 @@
#!/bin/sh
# pulse_move.sh [binary name] [sink name]
#
# Use pactl list short sinks to find sink names.
# Will move all streams from a certain binary to the sink.
SINK_ID=$(pactl -f json list short sinks |
jq -r ".[] | select(.name == \"$2\") | .index")
pactl -f json list clients |
jq -r ".[] | select(.properties.\"application.process.binary\" == \"$1\") | .index" |
while read -r clientindex; do
pactl -f json list short sink-inputs |
jq -r ".[] | select(.client == \"$clientindex\") | .index"
done |
while read -r inputindex; do
pacmd move-sink-input $inputindex $SINK_ID
done

View File

@ -1,16 +0,0 @@
#!/bin/sh
# Open word on Wiktionary in a browser
# Requires fzf
# Empty query to abort
# $1 sets the language to scroll to in the page
# wikt [language]
while true; do
WORD="$(cat ~/.local/bin/wikt-words | fzf | iconv -f UTF-8 -t ASCII//TRANSLIT | tr -d '-')"
if [ -z "$WORD" ]; then
break
fi
$BROWSER "https://wiktionary.org/wiki/$WORD#$1" > /dev/null 2>&1 &
done

File diff suppressed because it is too large Load Diff