When I want to record audio from line in, I have to open
pavucontrol, go to
Recording tab, click the dropdown menu and select
Built-In Audio Analog Stereo (green underlined), because the default entry is
**Monitor** of Built-In Audio Analog Stereo (red underlined)
I would make a bash script to set
Built-In Audio Analog Stereo, using
pacmd; I thought that would be enough to execute
pactl set-default-source alsa_input.pci-0000_00_1b.0.analog-stereo but doesn’t do nothing.
How can I achieve this need with a bash script?
I have found the solution which works as expected:
loopbackindex=$(pacmd list-source-outputs | tr '\n' '\r' | perl -pe 's/ *index: ([0-9]+).+?media\.name = "([^\r]+)"\r.+?(?=index:|$)/\2:\1\r/g' | tr '\r' '\n' | grep Loopback | cut -d ":" -f2)
pacmd move-source-output $loopbackindex alsa_input.pci-0000_00_1b.0.analog-stereo
PulseAudio has an option to specify the source devices for module-loopback
If you are loading the loopback module with the BASH script
pactl load-module module-loopback source=alsa_input.pci-0000_00_1b.0.analog-stereo
If the module is loaded in a default.pa configuration file omit the
pacmd commands can be a bit temperamental when used in BASH scripts and sometimes fail
some (but not all)
pactl commands work better without the daemon
There is a workaround for using
pacmd in scripts, if required
echo 'move-source-output $loopbackindex alsa_input.pci-0000_00_1b.0.analog-stereo' | pacmd
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.