Skip to content

Instantly share code, notes, and snippets.

@luca-c-xcv
Created March 23, 2023 18:44
Show Gist options
  • Save luca-c-xcv/8f75d92cf37204bb3c497643d4655dd7 to your computer and use it in GitHub Desktop.
Save luca-c-xcv/8f75d92cf37204bb3c497643d4655dd7 to your computer and use it in GitHub Desktop.
Change WiFi's status based on Ethernet connection
#!/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