I'm using a VPN service, but so far I've only been using it on my computer. Now I'd like to have it on my phone as well. The service I use allow up to four simultaneous connections, so that isn't an issue. They don't have their own client for Android, but they do make config files available for download and use with any client that supports OpenVPN. I've tried OpenVPN Connect, and it works quite well. However, whenever I switch between networks, for example when I lose my home WiFi on leaving my home, or when switching between public WiFis, it doesn't reconnect, so I have to remember to actively disconnect and reconnect.
I've tried setting up a macro in MacroDroid to automatically close OpenVPN Connect, wait for a few seconds, then reopen OpenVPN Connect, but all that does, is bring up the login screen, and I still have to manually click Connect.
My phone is rooted, and in case it matters, it's a Honor 8, FRD-L09 running EMUI 4.1. I'm not going to upgrade to 5.0 at this time, as TWRP and SuperSU have been reported not to be compatible with the EMUI 5.0 kernel. Other than that, I'm open to suggestions. I'm not afraid to play with shell scripts, as long as I have some understanding of what the script does, and with this, I have no idea how to implement it in a shell script, so if if you have such a solution, please also explain what it actually does.
EDIT: OpenVPN Connect has the ability to create shortcuts to disconnect and connect on the homescreen. I'm assuming that these shortcuts just pass arguments to the executable, telling it what to do, and what config file to use. If I knew how to find what arguments the shortcuts pass, I'd likely be able to write a shell script that I could then call from MacroDroid upon network change.