NetworkManager: toggle WiFi by Ethernet connectivity

If you are using NetworkManager and want turn off wifi on ethernet connections, this script may be useful for you.

Put this script in /etc/NetworkManager/dispatcher.d/ and eventually set the desired master interface.

#!/bin/bash
MASTER_INTERFACE="eth0"

case "$2" in
up)
  if [ "$1" = "$MASTER_INTERFACE" ]; then
    nmcli nm wifi off
  fi
;;

down)
  if [ "$1" = "$MASTER_INTERFACE" ]; then
    nmcli nm wifi on
  fi
;;

pre-up)
;;

post-down)
;;

*)
  echo $"Usage: $0 {up|down|pre-up|post-down}"
  exit 1
esac