Skip to content

Commit

Permalink
refactor(wifi): update signal strength mapping and icon assignment fo…
Browse files Browse the repository at this point in the history
…r accuracy
  • Loading branch information
amnweb committed Dec 10, 2024
1 parent 3e0c359 commit 48ca061
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/core/validation/widgets/yasb/wifi.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
},
'wifi_icons': [
"\udb82\udd2e", # Icon for 0% strength
"\udb82\udd1f", # Icon for 1-25% strength
"\udb82\udd22", # Icon for 26-50% strength
"\udb82\udd25", # Icon for 51-75% strength
"\udb82\udd28" # Icon for 76-100% strength
"\udb82\udd1f", # Icon for 1-24% strength
"\udb82\udd22", # Icon for 25-49% strength
"\udb82\udd25", # Icon for 50-74% strength
"\udb82\udd28" # Icon for 75-100% strength
],
'ethernet_icon': "\ueba9"
}
Expand Down
21 changes: 9 additions & 12 deletions src/core/widgets/yasb/wifi.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _get_wifi_strength(self):
for connection in connections:
if connection.get_network_connectivity_level() == NetworkConnectivityLevel.INTERNET_ACCESS:
signal_strength = connection.get_signal_bars()
return signal_strength * 20
return signal_strength
return 0

def _get_wifi_name(self):
Expand All @@ -151,17 +151,14 @@ def _get_wifi_name(self):
return "No WiFi"

def _get_wifi_icon(self):
# Map strength to its corresponding icon
strength = self._get_wifi_strength()
if strength == 0:
return self._wifi_icons[0], strength
elif strength <= 20:
return self._wifi_icons[1], strength
elif strength <= 40:
return self._wifi_icons[2], strength
elif strength <= 60:
return self._wifi_icons[3], strength
elif strength <= 80:
return self._wifi_icons[3], strength
else:
return self._wifi_icons[4], strength
elif strength == 1:
return self._wifi_icons[1], strength * 25
elif strength == 2:
return self._wifi_icons[2], strength * 25
elif strength == 3:
return self._wifi_icons[3], strength * 25
elif strength == 4:
return self._wifi_icons[4], strength * 25

0 comments on commit 48ca061

Please sign in to comment.