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