Pulseaudio loopback unload audio output devices

The appropriate way to unload modules

Unloading a module loaded to Pulse Audio is done by the module's index number, which is given on loading:

pactl load-module module-null-sink sink_name=test
24

In the above example Pulseaudio server loaded the module with index id 24. This module can be unloaded with the following command:

pactl unload-module 24

Your script will have to parse the output of pactl.

In case we do not know the module number we can issue the following command which will display the number and the module name:

pactl list short modules

Newer versions also allow unloading by name:

pactl unload-module <name>

The quick and dirty method

If pulseaudio is set up as auto-spawning demon (which should be the default begaviour) we may quickly unload all modules loaded after login with a reset of the PulseAudio server to load the default modules defined in our default.pa by running:

pulseaudio -k

This will effectively unload all modules from your script and will load the default sink for output.