Skip to content

Instantly share code, notes, and snippets.

@ethernetdan
Last active August 31, 2021 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ethernetdan/63caa3a0b46c391ed93c938da27de745 to your computer and use it in GitHub Desktop.
Save ethernetdan/63caa3a0b46c391ed93c938da27de745 to your computer and use it in GitHub Desktop.
Disables the WiFi device when the computer is docked and reenables it when it's undocked.
#!/bin/sh
# This script disables the WiFi device when the computer is docked and
# reenables it when it's undocked.
DOCK_DEVICE="enp0s31f6"
if [ "$1" != "$DOCK_DEVICE" ]; then
exit 0
fi
case "$2" in
up)
/usr/bin/nmcli radio wifi off
;;
down)
/usr/bin/nmcli radio wifi on
;;
esac
@ethernetdan
Copy link
Author

Should be placed in /etc/NetworkManager/dispatcher.d/20-wifi-dock-toggle.sh in an executable file owned by root and must have write permission only for owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment