nmcli dev wifi connect "$ssid" password "$password"&&{
colored_echo green "$success_msg"
break
}||{
colored_echo red "$failure_msg"
}
elif["$action"=="disconnect"];then
nmcli connection down "$ssid"&&{
colored_echo green "$success_msg"
break
}||{
colored_echo red "$failure_msg"
}
elif["$action"=="remove"];then
nmcli connection delete "$ssid"&&{
colored_echo green "$success_msg"
break
}||{
colored_echo red "$failure_msg"
}
fi
elif["$choice" -eq 0];then
return
else
colored_echo red "Invalid choice. Please try again."
fi
done
echo"Press any key to return to the main menu..."
read -n 1
}
# Function to connect to a WiFi network
connect_network(){
prompt_for_network "connect""Enter the number of the network to connect: ""Connected to the network successfully.""Failed to connect to the network."
}
# Function to disconnect from a WiFi network
disconnect_network(){
prompt_for_network "disconnect""Enter the number of the network to disconnect: ""Disconnected from the network successfully.""Failed to disconnect from the network."
}
# Function to remove a WiFi connection
remove_network(){
prompt_for_network "remove""Enter the number of the network to remove: ""Network removed successfully.""Failed to remove the network."