PlatformIO IDE: automate environment selection?

I want to automate the environment selection process in PlatformIO IDE.

My hope is to just click one of the default built targets (the ones that don’t mention an environment) and then my script would decide which environment would be the one actually used. The script would be included in the project.

Is there a way to hook into the PlatformIO IDE to do this?

In the Win10 environment, PlatformIO tends to be re-installed once or twice a week by the heavy users because Win10 just stops cooperating. I’m not fond of adding a custom button or menu item because it would have to be re-installed every time.

One of my ideas was to point the default environment to an environment that has an extra_script that does all the selection/updating but … I haven’t been able to find a method that results in the script being run early enough.

They already need to install platformio. Maybe adding another package to install isn’t so bad.

In the cold light of day and after looking through the low level code, those ideas aren’t sounding very practical.

The init code would have to look for a start script before it had made it’s decision on which environment to use.

I think the next thing to investigate is key bindings and how to easily share them with others & re-install when Windows forces another Atom/Platformio re-install.