Stream system audio to your friends over discord! (and other applications)

Approx 3 minutes read

On linux there isn’t any way to screen share with audio on popular video chat applications. Well who cares if the application doesn’t support it! With this script you have a finer control over what others hear. You can choose between your sound, system sound, both and can even chose which system sounds others can hear and what others can’t!

This is supposed to work on both pulseaudio and pipewire, I haven’t tried with pulse so just in case if you have any issues, please let me know.


default_source="$(pactl get-default-source)"
default_sink="$(pactl get-default-sink)"

# create virtual sinks
pactl load-module module-null-sink sink_name=VirtualSpeaker
pactl load-module module-null-sink media.class=Audio/Duplex sink_name=VirtualMicrophone

# create loopbacks
pactl load-module module-loopback source="VirtualSpeaker.monitor" sink="$default_sink"
pactl load-module module-loopback source="$default_source" sink="VirtualMicrophone"
pactl load-module module-loopback source="VirtualSpeaker.monitor" sink="VirtualMicrophone"

# set default mic
pactl set-default-source "VirtualMicrophone"

After running this script you’ll be able to choose VirtualMicrophone as the mic in any chat app; the last line of this script also ensures that this new mic is the default mic, you can remove this if you want.

How does this work?

This script basically creates a virtual speaker and a virtual microphone. You can listen to the virtual speaker on your physical speakers, while the virtual mic is always listening to both your virtual speaker and your virtual mic. So basically your voice and the playback is merged into this new mic.

Using pavucontrol you can change the playback device for each stream differently from the playback tab.

Further configurations

Common Issues

Please report any other issues to me! I’ll update this page for fixes if I think the issue worthy enough.