Skip to content

Commit 79cfaf9

Browse files
authored
Merge pull request #109 from ghostbsd/Issue#81
Adding signal string to tooltip
2 parents 13b4710 + 3841a9d commit 79cfaf9

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

NetworkMgr/net_api.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,26 +140,25 @@ def networkdictionary():
140140
return maindictionary
141141

142142

143-
def connectionStatus(card):
143+
def connectionStatus(card: str, network_info: dict) -> str:
144144
if card is None:
145145
netstate = "Network card is not enabled"
146146
elif 'wlan' in card:
147147
if not ifWlanDisable(card) and ifStatue(card):
148148
cmd1 = "ifconfig %s | grep ssid" % card
149149
cmd2 = "ifconfig %s | grep 'inet '" % card
150-
out1 = Popen(cmd1, shell=True, stdout=PIPE,
151-
universal_newlines=True)
152-
out2 = Popen(cmd2, shell=True, stdout=PIPE,
153-
universal_newlines=True)
154-
line1 = out1.stdout.read().strip()
155-
line2 = out2.stdout.read().strip()
156-
netstate = line1 + '\n' + subnetHexToDec(line2)
150+
out1 = Popen(cmd1, shell=True, stdout=PIPE, universal_newlines=True)
151+
out2 = Popen(cmd2, shell=True, stdout=PIPE, universal_newlines=True)
152+
ssid_info = out1.stdout.read().strip()
153+
inet_info = out2.stdout.read().strip()
154+
ssid = network_info['cards'][card]['state']["ssid"]
155+
percentage = network_info['cards'][card]['info'][ssid][4]
156+
netstate = f"Signal Strength: {percentage}% \n{ssid_info} \n{subnetHexToDec(inet_info)}"
157157
else:
158158
netstate = "WiFi %s not connected" % card
159159
else:
160160
cmd = "ifconfig %s | grep 'inet '" % card
161-
out = Popen(cmd, shell=True, stdout=PIPE,
162-
universal_newlines=True)
161+
out = Popen(cmd, shell=True, stdout=PIPE, universal_newlines=True)
163162
line = out.stdout.read().strip()
164163
netstate = subnetHexToDec(line)
165164
return netstate

NetworkMgr/trayicon.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def stop_manager(self, widget):
4141
Gtk.main_quit()
4242

4343
def __init__(self):
44+
self.if_running = False
45+
self.cardinfo = None
4446
self.statusIcon = Gtk.StatusIcon()
4547
self.statusIcon.set_visible(True)
4648
self.statusIcon.connect("activate", self.leftclick)
@@ -305,7 +307,7 @@ def updatetrayicon(self, defaultdev, card_type):
305307
self.statusIcon.set_from_icon_name(icon_name)
306308

307309
def trayStatus(self, defaultdev):
308-
self.statusIcon.set_tooltip_text(connectionStatus(defaultdev))
310+
self.statusIcon.set_tooltip_text(connectionStatus(defaultdev, self.cardinfo))
309311

310312
def tray(self):
311313
self.if_running = False

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from setuptools import setup
88
from subprocess import run
99

10-
__VERSION__ = '6.3'
10+
__VERSION__ = '6.5'
1111
PROGRAM_VERSION = __VERSION__
1212

1313
prefix = '/usr/local' if system() == 'FreeBSD' else sys.prefix

0 commit comments

Comments
 (0)