Is there a way to create a lovelace button that toggles between two scripts running adb commands to an Nvidia Shield?

I want to create a button that turns an app playing in an Nvidia Shield TV on or off.
I have created scripts that send the relevant adb commands to the Shield.
More specifically, here’s an example in steps:

  1. Nvidia Shield is running Netflix
  2. I press a lovelace button named “Disney+” to switch to Disney+
  3. A script runs that closes Netflix
  4. Netflix closes (not hidden in the background, actually close)
  5. A script runs that opens Disney+
  6. Disney+ opens

I am looking to do this in a way that when someone taps on the Disney+ button, the scripts in steps 3 and 5 above run automatically, one after the other, with some time delay between them if needed.

At the moment, I have 4 buttons as follows:

  • One to open Netflix
  • One to close Netflix
  • One to open Disney+
  • One to close Disney+

As you understand this is rather impractical, especially when you consider more apps that I need to run (Jellyfin, Kodi, TuneIn etc).

In addition to the above, I’d like to ensure that all other apps are closed before an app opens. So, instead of closing just Netflix with a script, is there a way to close all other potentially running apps (Kodi, TuneIn etc.) before opening Disney+ in the example above?

Hope this makes sense.