Added Wifi Signal Strenght Indicators
This commit is contained in:
1 parent
13fa65237b
commit
d91c61d806
13 files changed
+483
-78
No files matched your search
@@ -49,3 +49,49 @@ def read_json_file(file_path: str) -> Optional[List]:
|
||||
except json.JSONDecodeError as e:
|
||||
logger.error(f"Failed to read JSON file {file_path}: {e}")
|
||||
return None
|
||||
|
||||
|
||||
def get_wifi_icon_for_strength(strength: int) -> str:
|
||||
"""
|
||||
Get the appropriate WiFi icon based on signal strength.
|
||||
|
||||
Args:
|
||||
strength: Signal strength from 0-100
|
||||
|
||||
Returns:
|
||||
Absolute path to the appropriate WiFi icon
|
||||
"""
|
||||
# Get the current directory where this script is located
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
# Get the project root (parent of utils directory)
|
||||
project_root = os.path.dirname(current_dir)
|
||||
|
||||
if strength >= 80:
|
||||
icon_name = "network-wireless-100.svg"
|
||||
elif strength >= 60:
|
||||
icon_name = "network-wireless-80.svg"
|
||||
elif strength >= 40:
|
||||
icon_name = "network-wireless-60.svg"
|
||||
elif strength >= 20:
|
||||
icon_name = "network-wireless-40.svg"
|
||||
elif strength > 0:
|
||||
icon_name = "network-wireless-20.svg"
|
||||
else:
|
||||
icon_name = "network-wireless-0.svg"
|
||||
|
||||
return os.path.join(project_root, "config", "assets", "icons", "wifi", icon_name)
|
||||
|
||||
|
||||
def get_wifi_connecting_icon() -> str:
|
||||
"""
|
||||
Get the WiFi connecting icon path.
|
||||
|
||||
Returns:
|
||||
Absolute path to the WiFi connecting icon
|
||||
"""
|
||||
# Get the current directory where this script is located
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
# Get the project root (parent of utils directory)
|
||||
project_root = os.path.dirname(current_dir)
|
||||
|
||||
return os.path.join(project_root, "config", "assets", "icons", "wifi", "wifi-connecting.svg")
|
||||
Reference in new issue
Block a user