Trigger Macro Once When Switching to Application?

Unfortunately not. The only way to switch Stream Deck profiles is to associate them with an app. Therefore you make a blank app using a script editor, then momentarily run it in order to trigger the profile switch. Explained at length here:

edit: I've found an inelegant solution to that problem and encountered another. I added an action to activate Logic again before the loop-breaking pause, so it now works when Logic doesn't have an open window.

New problem: KM isn't reliably re-enabling the macro. There must be a better way to do this...