Ubuntu disable wifi on ethernet connection
When I dock my laptop with ethernet connected I would like the wifi to turn off as it sits in the dock with the lid shut drifting in and out of wifi signal range, very annoying. This also will force the connection over the faster ethernet connection as sometimes it likes to use the wifi when both are connected. (despite setting the priority!)
This simple script runs nmcli when Network Manager sees eth0 go up and down and turns wifi on or off appropriately. (It actually runs when anything goes up and down, arg1 $1 is the interface and arg2 $2 is the interface state)
sudo nano /etc/NetworkManager/dispatcher.d/50wifioff
Cut n paste the below , you can remove the logger comments if you wish (logger writes what is going on into /var/log/syslog)
#!/bin/bash logger "Running $0" case "$1" in eth*) if [ "$2" == up ]; then logger "$1 $2 wifi off" nmcli radio wifi off elif [ "$2" == down ]; then logger "$1 $2 wifi on" nmcli radio wifi on fi ;; esac
Make it executable
sudo chmod 755 /etc/NetworkManager/dispatcher.d/50wifioff
Finally no annoying wifi connected/disconnected messages or ending up with both wireless and wired connected and going over wrong one
Comments
blog comments powered by Disqus