Ubuntu: Turn off WiFi when connected to Thunderbolt dock


I have an XPS 13 with Dell's own TB-16 dock. Despite the lack of official Linux support it works really well, as long as WiFi is turned off. This is okay since I have a wired connection at my desk, but if I try to boot with the dock connected it won't work since it crashes before I can log in and turn off the WiFi.

I suppose I could craft some script that detects the dock itself or maybe a specific USB device (like the keyboard) connected to it, but only if I connect the dock while the system is on. In that case I can just turn off WiFi manually anyway.

Is there some way to make sure that the WiFi is never activated in the first place whenever I boot with the dock connected? Alternatively, can it just always be turned off at every reboot? Having to turn it on manually is not so bad since my laptop is docked most of the time.


I use the following script to handle whether wifi should be active based on an ethernet connection. You could likely make minor edits for your use case and connection names (e.g. "eth0"). You will need to chmod +x and permission as necessary ...

With NetworkManager, it sits in /etc/NetworkManager/dispatcher.d/


#!/usr/bin/env bash    if [ "$1" = "eth0" ] || [ "$1" = "eno1" ]; then      case "$2" in          up)              logger "[Script] Ethernet connect detected. Turning Wifi radio OFF";              nmcli radio wifi off              ;;          down)              logger "[Script] Ethernet disconnect detected. Turning Wifi radio ON";              nmcli radio wifi on              ;;      esac  fi  

Here is a reference to NetworkManager events ($2) that may be helpful: https://developer.gnome.org/NetworkManager/stable/NetworkManager.html

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »