Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Bash script to automatically connect to open WiFi networks, upon disconnect, via nmcli
if [[ -z "$con" ]]; then
echo "Please provide an interface name as an argument."
exit 1
while true; do
conns=$(nmcli con show "$con" | grep "GENERAL.STATE:" | grep "activated")
if [[ -z "$conns" ]]; then
echo "$con is not active; scanning...."
nmcli device wifi rescan
# nmcli device wifi list
nmcli -f SSID dev wifi
nmcli device wifi connect SSID-Name # password wireless-password
sleep 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.