i have a docking station for my laptop. so i dont always use wifi. i have also configured static ip addresses for both wifi and cable connections. the same ip address for both.
so i sat down and wrote a script to be run by crontab every minute that would check to see whether i was on the ethernet cable or using the wifi connection. and it would disable the other. i have commented out info messages as i use it from crontab very succesfully. also this script can be run as a normal user.
#!/bin/sh
/bin/nmcli d |grep ethernet |grep connected > /dev/null
wired=$?
if [ $wired -eq 0 ]
then
# echo "INFO: em1 in use"
if [ `nmcli r| awk '{print $2}'| tail -1` == "enabled" ]
then
# echo "INFO: Wifi enabled"
# echo "INFO: Turning radio off"
nmcli radio wifi off
fi
else
# echo "INFO: Turning radio on"
nmcli radio wifi on
fi