I’m wondering on a way to run a script when plexamp starts playing music with a headless RaspberryPi.
Ideally I’m trying to do some HDMI CEC command to control my soundbar to turn it on and change the input to the Pi when starting music and change it back when stopping. Just not sure if theres a way to do this currently.
Your best bet is probably to use Plex’s webhooks feature to implement this. When configured correctly, Plex Media Server will send an HTTP(S) request to a configured web server when certain events occur on the server (including starting, pausing, and stopping media playback). This request will contain a JSON payload containing information about the event including the media being played. You can act upon this event in whatever manner makes sense for your use case.
I imagine you could run a small node.js app on the same Pi that runs Plexamp. There are a few examples above.