External relay/switch

I would like to enable a external battery power source in addition to the BEC that currently powers the pixhawk and would be convenient to allow the pixhawk to enable the backup power once the safety switch is pressed via an AUX port or similar…
Can these events (safety switch, armed, etc) be linked or mapped to a AUX port state?
This way one of the AUX ports can be triggered to a logic state of 3v3(?) depending on other factors like when armed or battery low or excessive current draw, etc.
Will give some more flexibility to the system for some perhaps?

the Pixhawk will automatically switch between USB, power module, and Servo rail for it’s input rail

You don’t need to have a separate enable for it.