Skip to content

Commit

Permalink
refactor(widgets): Update WifiWidget to use NetworkInformation API fo…
Browse files Browse the repository at this point in the history
…r retrieving wifi information
  • Loading branch information
amnweb committed Oct 14, 2024
1 parent 403b895 commit 36d89cc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/core/widgets/yasb/wifi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import re
from winsdk.windows.networking.connectivity import NetworkInformation
from winsdk.windows.networking.connectivity import NetworkInformation, NetworkConnectivityLevel
from core.widgets.base import BaseWidget
from core.validation.widgets.yasb.wifi import VALIDATION_SCHEMA
from PyQt6.QtWidgets import QLabel, QHBoxLayout, QWidget
Expand Down Expand Up @@ -138,15 +138,15 @@ def _update_label(self):
def _get_wifi_strength(self):
connections = NetworkInformation.get_connection_profiles()
for connection in connections:
if connection.is_wlan_connection_profile:
if connection.get_network_connectivity_level() == NetworkConnectivityLevel.INTERNET_ACCESS:
signal_strength = connection.get_signal_bars()
return signal_strength * 20
return 0

def _get_wifi_name(self):
connections = NetworkInformation.get_connection_profiles()
for connection in connections:
if connection.is_wlan_connection_profile:
if connection.get_network_connectivity_level() == NetworkConnectivityLevel.INTERNET_ACCESS:
return connection.profile_name
return "No WiFi"

Expand Down

0 comments on commit 36d89cc

Please sign in to comment.