Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding signal string to tooltip #109

Merged
merged 3 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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