Set WiFi Priority
Description
The set_wifi_priority function sets the autoconnect priority for a specific Wi-Fi connection.
Function Signature:
def set_wifi_priority(ssid: str, priority: int) -> None:
Parameters
- ssid: The SSID (name) of the Wi-Fi connection.
- priority: The autoconnect priority to set for the Wi-Fi connection.
Returns
- None
Example Usage
set_wifi_priority("YourSSID", 100)
Notes
This function uses nmcli to retrieve the UUID of the specified connection and set its autoconnect priority. Then, it restarts the NetworkManager service to apply the changes.
- The function will raise a
ValueErrorif the connection is not found. - If the
nmclicommands fail, asubprocess.CalledProcessErrorwill be caught and the error message will be printed.
Error Handling
- If the
nmclicommands fail (e.g., due to incorrect input or missing permissions), asubprocess.CalledProcessErrorwill be caught and the error message will be printed. - If the connection with the specified SSID cannot be found, a
ValueErrorwill be raised with a message indicating the connection was not found.