1

I'm trying to check if any sound is coming out of my audio device from cli particularly. I've tried

cat /proc/asound/card*/pcm*/sub0/status

to get the status of the audio but however even when there's no sound playing I get results like this

owner_pid   : 2784
trigger_time: 12480.406201499
tstamp      : 14574.205418430
delay       : 1248
avail       : 86421
avail_max   : 86421
-----
hw_ptr      : 100504320
appl_ptr    : 100505280

I'm probably looking at this in the wrong but my end goal is to execute a command if no sound is playing for considerable amount of time.

shriek
  • 187
  • 4
  • 16

1 Answers1

1

Hah! After 3 years I searched for this same question and didn't even realize that I had landed on my very own question.
Well, at-least for my future self here's the solution and some other notes.

cat /proc/asound/card*/pcm0p/sub0/status | grep -i running || <audio_not_running_cmd.sh>

The above command will run <audio_not_running_cmd.sh> if it fails to find any audio device that are not running.
Note: If you have PulsoAudio Volume window open then it will show "RUNNING" all the time. Try closing that window and the status should show closed after 4-5 seconds.

So with the above result you can just plop that script in your crontab and periodically check if your audio device is sleeping.

shriek
  • 187
  • 4
  • 16