The Cookie Machine - Click here to drag window

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

If you can read me, I'm broken!

Views: 786     Votes:  2     ✅ 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: September 15, 2024    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  ⇩