Making a bash script that reconnect to AP when connection lost
- by Alexander
I'm facing problems with WIFI on ubuntu
i tried to update the system but still the same
what happens is that i suddenly lose the connection with my router
and when i press on the WIFI bar the system won't detect any APs
i have to uncheck "enable WIFI" option ,then re check it so it work,it automatically reconnect.
I'm thinking of making a bash script that detects when the pc is disconnected from the router for any reason, and when it is disconnected it disable then enable the wifi.
i mean like automating resetting the connection that possible ?
i guess i must use this
nmcli nm wifi off
nmcli nm wifi on
but how can i make the script know if the PC is disconnected from the WIFI ?