Skip to content

Commit

Permalink
Merge pull request #109 from ghostbsd/Issue#81
Browse files Browse the repository at this point in the history
Adding signal string to tooltip
  • Loading branch information
ericbsd authored Jul 24, 2024
2 parents 13b4710 + 3841a9d commit 79cfaf9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
19 changes: 9 additions & 10 deletions NetworkMgr/net_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion NetworkMgr/trayicon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 79cfaf9

Please sign in to comment.