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
ValueError
if the connection is not found. - If the
nmcli
commands fail, asubprocess.CalledProcessError
will be caught and the error message will be printed.
Error Handling
- If the
nmcli
commands fail (e.g., due to incorrect input or missing permissions), asubprocess.CalledProcessError
will be caught and the error message will be printed. - If the connection with the specified SSID cannot be found, a
ValueError
will be raised with a message indicating the connection was not found.