The credit for most of the code belongs to others including https://gist.github.com/albertbori/1798d88a93175b9da00b
This program turns off WiFi when it detects a wired ethernet connection and turns on WiFi when the ethernet is unplugged.
Tested on Catalina
git clone https://github.com/mpsalisbury/toggleairport.git
cd toggleairport
./install.sh
to uninstall just do
./uninstall.sh
Do not run either of the scripts with sudo, if you do, notifications will not display.