Skip to content

Instantly share code, notes, and snippets.

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 mika/cf280c78432e3b3479dc77e9d9a0774e to your computer and use it in GitHub Desktop.
Save mika/cf280c78432e3b3479dc77e9d9a0774e 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
#!/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