Skip to content

Instantly share code, notes, and snippets.

@djanatyn
Last active November 16, 2015 20:54
Show Gist options
  • Save djanatyn/8c0716dcb7aba4747685 to your computer and use it in GitHub Desktop.
Save djanatyn/8c0716dcb7aba4747685 to your computer and use it in GitHub Desktop.
#!/usr/bin/bash
#script to turn off wifi if ethernet cable is connected
#and turn wifi back on if the wifi interfaces are down and ethernet is not connected
#variables that
eth_state =$(< /sys/class/net/enp0s25/carrier)
wifi =$(< /sys/class/net/wlp3s0/operstate)
usb_wifi = $(< /sys/class/net/wlp0s29u1u1/operstate)
if [ $eth_state -eq 1 ]; then
nmcli radio wifi off
elif [ $wifi = 'down' ] && [ $usb_wifi = 'down' ] && [ $eth_state -eq 0 ]; then
nmcli radio wifi on
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment