Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Problem: Python scripting - run script when moode plays/stops
#2
Here's how I do it. Two files:

autoamp.sh
autoamp.service

Put the first in your home directory. Put the second in /etc/systemd/system/

Then run

sudo systemctl enable autoamp.service
sudo systemctl daemon-reload
sudo systemctl start autoamp.service

The 1st file, which I borrowed from someone (thanks!), polls the /proc/asound/card0/pcm0p/sub0/status virtual file (this works for my set-up, you might need to alter which file it polls depending on yours) for the text "RUNNING". This only appears when sound is playing. If it finds it, then it changes the state of your specified GPIO pin (in my case 23). If it doesn't find it, then no change. If it did find it, but then it doesn't anymore, then the state is changed as well. There's a counter in there for a delay on this change.

Hope this helps.


Attached Files
.zip   autoamp.zip (Size: 1.04 KB / Downloads: 17)
Reply


Messages In This Thread
RE: Python scripting - run script when moode plays/stops - by tristanc - 02-26-2019, 10:28 AM

Forum Jump: