Last active
October 9, 2023 16:36
-
-
Save cengiz-io/c9023b83a8590dd2c723f3181633c99a to your computer and use it in GitHub Desktop.
Script should be placed under `/etc/NetworkManager/dispatcher.d/` with a name like `99-disable-wireless-when-wired`. Make sure 1) root owns it 2) it's mod is 755
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 | |
IFACE=$1 | |
ACTION=$2 | |
ntfy () { | |
sudo -u cengiz \ | |
DISPLAY=:0 \ | |
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus \ | |
notify-send "$1" "$2" | |
} | |
case ${IFACE} in | |
eth*|usb*|en*) | |
case ${ACTION} in | |
up) | |
ntfy "Ethernet connected" "Disabling Wifi" | |
nmcli radio wifi off | |
;; | |
down) | |
ntfy "Ethernet disconnected" "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
Reading
man nmcli-examples
for deeper options...