Skip to content

Commit

Permalink
Fixed reconnecting switch bug and zombie status checker
Browse files Browse the repository at this point in the history
  • Loading branch information
Corewala committed Apr 30, 2021
1 parent 197c381 commit 8a3d3ac
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions smother.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,16 @@ def __init__(self):
self.killbutton.set_sensitive(not self.config["enabled"])
self.unkillbutton.set_sensitive(self.config["enabled"])
self.port.set_value(self.config["port"])
self.reconnectingswitch.set_state(self.config["reconnecting"])
self.settingsbox.set_sensitive(not self.config["enabled"])
if self.config["reconnecting"]:
# this is a bad workaround but it works
self.reconnectingswitch.set_state(True)
self.config["reconnecting"] = True
yaml.safe_dump(self.config, open(self.configPath, "r+"))
self.port.set_sensitive(self.reconnectingswitch.get_state())
self.applybutton.set_sensitive(self.reconnectingswitch.get_state())
if self.config["enabled"]:
Thread(target = self.status_check, args = ()).start()

def on_reconnecting_changed(self, widget, state):
self.config["reconnecting"] = not self.reconnectingswitch.get_state()
Expand Down Expand Up @@ -97,6 +104,7 @@ def enable(self):
yaml.safe_dump(self.config, open(self.configPath, "r+"))
os.system("notify-send 'Smother' 'Killswitch enabled' -i smother")
Thread(target = self.status_check, args = ()).start()
self.settingsbox.set_sensitive(False)
print("\33[92m" + "Killswitch enabled" + "\33[0m")
elif commandstatus != 32256:
self.killbutton.set_sensitive(True)
Expand All @@ -115,6 +123,7 @@ def disable(self):
self.config["enabled"] = False
yaml.safe_dump(self.config, open(self.configPath, "r+"))
os.system("notify-send 'Smother' 'Killswitch disabled' -i smother")
self.settingsbox.set_sensitive(True)
print("\33[92m" + "Killswitch disabled" + "\33[0m")
elif commandstatus != 32256:
self.unkillbutton.set_sensitive(True)
Expand All @@ -126,7 +135,8 @@ def disable(self):

def status_check(self):
vpnstatus = True
while self.config["enabled"]:
time.sleep(2)
while self.config["enabled"] and win.get_window():
if not os.system("nmcli device status | grep \"tun0\" &> /dev/null"):
vpnstatus = True
else:
Expand Down

0 comments on commit 8a3d3ac

Please sign in to comment.