I'm running Debian (technically Raspbian), trying to get a Star-Trek style voice-command system. I've got it mostly up and running, but in the interests of privacy and all that jazz, I don't want my microphone always recording.

I'm wondering, is there a way to poll which processes, if any, are currently accessing the microphone? The idea is that I'd make myself a little indicator to tell if the microphone was currently recording audio or not.

My ultimate goal is to turn the microphone on and off using a TV-remote, and to have an LED indicator for if it's on or off. I've got all the hardware stuff working, I just need the software end now.

I believe that right now I'm configured in pure ALSA i.e. not PulseAudio, though I could be wrong.

2 Answers 2


First identify your microphone device file; should be something similar to /dev/snd/pcmC0D0c. To help you find the device file, you can start a test recording with arecord or such, then do lsof | grep '/dev/snd'; it will list all programs and their associated device file.

Then you can peek usage of the microphone using fuser /dev/snd/pcmC0D0c. It will return the PID of the program accessing the device, if said device is opened.

You may prefer to loop on inotifywait /dev/snd/pcmC0D0c alternatively, to detect changes in state instead of constantly polling the device for status.


The field owner_pid in the procfs file status of a PCM device shows which program has opened it:

$ grep owner_pid /proc/asound/card*/pcm*/sub*/status
/proc/asound/card2/pcm0p/sub0/status:owner_pid   : 1803
$ ps -p 1803
  PID TTY          TIME CMD
 1803 pts/0    00:00:00 aplay

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .