The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

Views: 230     Votes:  1     ✅ Solution
Tags: networking   network-manager   ethernet  
Link: 🔍 See Original Answer on Ask Ubuntu 🔗

URL: https://askubuntu.com/q/1394492
Title: Frequent switches between Ethernet and Wifi
ID: /2022/02/23/Frequent-switches-between-Ethernet-and-Wifi
Created: February 23, 2022
Upload: November 24, 2022    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


I had a problem last year:

The solution there could work for you:


A script that automatically disables WiFi when Ethernet (Network) is connected:

#!/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

The script has to be created in a specific directory. After creation mark it executable:

chmod a+x /etc/NetworkManager/dispatcher.d/70-wifi-wired-exclusive.sh
⇧ stdin: invalid argument Unable to lock screen with Cron or Settings  ⇩