Created
March 23, 2023 18:44
-
-
Save luca-c-xcv/8f75d92cf37204bb3c497643d4655dd7 to your computer and use it in GitHub Desktop.
Change WiFi's status based on Ethernet connection
This file contains hidden or 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/bash | |
export LC_ALL=C | |
ETH_STATUS=$(nmcli device | grep -w "connected" | grep "ethernet") | |
function handler() | |
{ | |
if [[ -n "$ETH_STATUS" ]]; then | |
nmcli radio wifi off | |
else | |
nmcli radio wifi on | |
fi | |
} | |
if [[ "$2" == "up" ]]; then | |
handler | |
fi | |
if [[ "$2" == "down" ]]; then | |
handler | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment