3

I know it is possible to check whether the webcam is currently opened or not. But is there a similar way to check whether it is currently being recording from a microphone?

I was poking around a bit in /dev/snd/, had a quick look at Pulseaudio functionality, and was running up and down the web. Unfortunately I couldn't find an easy solution. A general solution that does not rely on Pulseaudio would be ideal.

1 Answers1

3

A general solution that does not rely on Pulseaudio would be ideal.

Most if not all popular modern Linux distros use Pulseaudio which opens ALSA kernel devices and keeps them open at all times which means the solution must probably involve it.

Also if PA is installed and running, applications cannot read from/write to ALSA kernel devices because PA opens them exclusively.

Here's a quick command for PulseAudio which, if it returns any output, means your input devices are being used:

pacmd list-sources | grep RUNNING

For PipeWire that will be:

pactl list sources | grep RUNNING
  • You confirmed some suspicions (never really got into PA) and the suggested command is exactly what I needed. Thank you for the on-point explanation and the perfect solution! – creativecoding Apr 15 '21 at 08:06
  • 1
    Consider this command as well pactl list short | grep RUNNING - it shows all used devices and outputs some nice parsable info about them. – Artem S. Tashkinov Apr 15 '21 at 08:51
  • 1
    Awesome, thank you! That's better than grepping for the state. I can't believe I missed those commands. Somehow pacmd and those options to pactl completely went unnoticed. Need to brush up on PA I guess. – creativecoding Apr 15 '21 at 09:01