Last active
December 11, 2023 11:08
-
-
Save tmonjalo/6da7a576e35a4cd2a968894c693ae7f4 to your computer and use it in GitHub Desktop.
Toggle wifi status on ethernet event with Linux NetworkManager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# path should be /etc/NetworkManager/dispatcher.d/99-auto-wireless | |
self=${0##*/} | |
log() { logger -p user.info -t "${self}[$$]" "$*" ;} | |
iface=$1 | |
action=$2 | |
case $iface in eth*|usb*|en*) | |
case $action in | |
up) | |
log "disabling wifi" | |
nmcli radio wifi off ;; | |
down) | |
[ -z "$(ip route show to default)" ] || exit 0 | |
log "enabling wifi" | |
nmcli radio wifi on ;; | |
esac | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment