Courtesy of distroguy blog post
cat << \EOF |sudo tee /etc/NetworkManager/dispatcher.d/70-wifi-wired-exclusive.sh
#!/bin/bash
export LC_ALL=C
enable_disable_wifi ()
{
result=$(nmcli dev | grep "ethernet" | grep -w "connected")
if [ -n "$result" ]; then
nmcli radio wifi off
else
nmcli radio wifi on
fi
}
if [ "$2" = "up" ]; then
enable_disable_wifi
fi
if [ "$2" = "down" ]; then
enable_disable_wifi
fi
EOF
sudo chown root:root /etc/NetworkManager/dispatcher.d/70-wifi-wired-exclusive.sh
sudo chmod 744 /etc/NetworkManager/dispatcher.d/70-wifi-wired-exclusive.sh
sudo systemctl restart NetworkManager
Links