Making a BTT button visible when music is playing or not

I'm currently trying to add my own custom skip controls for apple music on a BTT touch bar.
I'm using the preset 'now playing widget' and it is set to 'hide if no player is running'. When this widget is hidden, if I used the preset Next/previous touch bar buttons, they would remain on my touch bar since there is no option to 'hide if no player is running

To try to solve this I have on either side of this widget an apple script widget that triggers the 'Next'/'Previous' action. The script for these is as follows:

Screen Shot 2021-10-07 at 16.03.23

This all works as expected and hides the skip buttons when a song is paused because it returns nothing. The trouble with this is when I try now try to quit the Music application it immediately re-opens... presumably because this script is continually telling it to return a value. Another annoying problem is the skip buttons disappearing in a glitchy delayed manner unless I run the script every 0.05 seconds, which can't be good for battery life!?

Does anyone have any ideas how I can minimize this glitching and prevent the script from re-opening the app when I try to quit it?

I also added a volume slider group that is opened by a Named Trigger that is triggered by a long press of the now playing widget. Surely there's a simpler way of doing this?

Imprint | Privacy Policy