From 247cc276f9ab269148b84cca8ea95c7017fa1ebd Mon Sep 17 00:00:00 2001 From: Edu_Amr Date: Tue, 23 Jul 2024 19:49:09 -0300 Subject: [PATCH 1/3] Adding signal string to tooltip --- NetworkMgr/net_api.py | 16 ++++++++-------- setup.py | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/NetworkMgr/net_api.py b/NetworkMgr/net_api.py index ccce511..5073247 100755 --- a/NetworkMgr/net_api.py +++ b/NetworkMgr/net_api.py @@ -140,20 +140,20 @@ def networkdictionary(): return maindictionary -def connectionStatus(card): +def connectionStatus(card: str, network_info: dict) -> str: if card is None: netstate = "Network card is not enabled" elif 'wlan' in card: if not ifWlanDisable(card) and ifStatue(card): cmd1 = "ifconfig %s | grep ssid" % card cmd2 = "ifconfig %s | grep 'inet '" % card - out1 = Popen(cmd1, shell=True, stdout=PIPE, - universal_newlines=True) - out2 = Popen(cmd2, shell=True, stdout=PIPE, - universal_newlines=True) - line1 = out1.stdout.read().strip() - line2 = out2.stdout.read().strip() - netstate = line1 + '\n' + subnetHexToDec(line2) + out1 = Popen(cmd1, shell=True, stdout=PIPE, universal_newlines=True) + out2 = Popen(cmd2, shell=True, stdout=PIPE, universal_newlines=True) + ssid_info = out1.stdout.read().strip() + inet_info = out2.stdout.read().strip() + ssid = network_info['cards'][card]['state']["ssid"] + percentage = network_info['cards'][card]['info'][ssid][4] + netstate = f"{ssid_info} - Signal Strength: {percentage} % \n{subnetHexToDec(inet_info)}" else: netstate = "WiFi %s not connected" % card else: diff --git a/setup.py b/setup.py index 7be091b..598b4fe 100755 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ from setuptools import setup from subprocess import run -__VERSION__ = '6.3' +__VERSION__ = '6.5' PROGRAM_VERSION = __VERSION__ prefix = '/usr/local' if system() == 'FreeBSD' else sys.prefix From 7ebd04b7786dd480bcbcf4b91efb161d8ee0070d Mon Sep 17 00:00:00 2001 From: Edu_Amr Date: Tue, 23 Jul 2024 20:09:51 -0300 Subject: [PATCH 2/3] Added card info to the set_tooltip_text call. --- NetworkMgr/trayicon.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NetworkMgr/trayicon.py b/NetworkMgr/trayicon.py index 7676bd2..76fcc51 100755 --- a/NetworkMgr/trayicon.py +++ b/NetworkMgr/trayicon.py @@ -41,6 +41,8 @@ def stop_manager(self, widget): Gtk.main_quit() def __init__(self): + self.if_running = False + self.cardinfo = None self.statusIcon = Gtk.StatusIcon() self.statusIcon.set_visible(True) self.statusIcon.connect("activate", self.leftclick) @@ -305,7 +307,7 @@ def updatetrayicon(self, defaultdev, card_type): self.statusIcon.set_from_icon_name(icon_name) def trayStatus(self, defaultdev): - self.statusIcon.set_tooltip_text(connectionStatus(defaultdev)) + self.statusIcon.set_tooltip_text(connectionStatus(defaultdev, self.cardinfo)) def tray(self): self.if_running = False From 3841a9db270374b97a63fb68dc0cb78f44213522 Mon Sep 17 00:00:00 2001 From: Edu_Amr Date: Tue, 23 Jul 2024 20:35:57 -0300 Subject: [PATCH 3/3] Reformatted the netstate so it better displays network information --- NetworkMgr/net_api.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/NetworkMgr/net_api.py b/NetworkMgr/net_api.py index 5073247..770d52e 100755 --- a/NetworkMgr/net_api.py +++ b/NetworkMgr/net_api.py @@ -153,13 +153,12 @@ def connectionStatus(card: str, network_info: dict) -> str: inet_info = out2.stdout.read().strip() ssid = network_info['cards'][card]['state']["ssid"] percentage = network_info['cards'][card]['info'][ssid][4] - netstate = f"{ssid_info} - Signal Strength: {percentage} % \n{subnetHexToDec(inet_info)}" + netstate = f"Signal Strength: {percentage}% \n{ssid_info} \n{subnetHexToDec(inet_info)}" else: netstate = "WiFi %s not connected" % card else: cmd = "ifconfig %s | grep 'inet '" % card - out = Popen(cmd, shell=True, stdout=PIPE, - universal_newlines=True) + out = Popen(cmd, shell=True, stdout=PIPE, universal_newlines=True) line = out.stdout.read().strip() netstate = subnetHexToDec(line) return netstate