MagicMirror² v2.14.0 is available! For more information about this release, check out this topic.

Execute script (GPIO Relay) based on if sound is being played

  • Hi guys, I want to monitor if audio is being played, e.g:

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

    And if any status contains running I want to execute a script (in my case turn on the amplifier). I want a simple solution and initially I thought it might be possible with udev or python or bash. Does any of you have a great and easy idea?


  • while sleep 1; do
      if grep -q 'RUNNING' '/proc/asound/card0/pcm0p/sub0/status';
        echo "Running!"
        echo "Not Running!"

    this seems to work but the amplifier produces a too loud cracking sound when switching on, I have two spare relais und my MagicMirror, I will hook up the speakers to those and try again.

Log in to reply