diff --git a/NetworkMgr/net_api.py b/NetworkMgr/net_api.py index ccce511..770d52e 100755 --- a/NetworkMgr/net_api.py +++ b/NetworkMgr/net_api.py @@ -140,26 +140,25 @@ 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"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 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 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