Skip to content

Commit

Permalink
Fix config rewrite when exiting the app
Browse files Browse the repository at this point in the history
  • Loading branch information
XAli-SHX committed Mar 29, 2023
1 parent 6d4c263 commit 37aa46e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions main.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ from PIL import Image
import os
import threading

appIsRunning = True


class Const:
CONFIG_FILE_PATH = "./config.txt"
Expand Down Expand Up @@ -87,10 +89,12 @@ def onIconRightClicked(stray, query):
elif query == Const.STRAY_OPEN_CONFIG:
openConfigFile()
elif query == Const.STRAY_EXIT:
config.en = False
config.writeConfig()
# config.en = False
# config.writeConfig()
global appIsRunning
appIsRunning = False
stray.stop()
exit(0)
# exit(0)
config.writeConfig()


Expand Down Expand Up @@ -118,7 +122,7 @@ def setupStray():
def main():
config = Config()
showSystemStatus(config)
while True:
while appIsRunning:
battery = psutil.sensors_battery()
isPluggedIn = battery.power_plugged
if isPluggedIn:
Expand All @@ -129,7 +133,6 @@ def main():
sendNotification("Low Battery, Plug-in charger", ("The Power is at " + str(battery.percent)))
time.sleep(config.alertTimeInterval)
config.readConfig()
print('hey')


def showSystemStatus(config: Config):
Expand Down

0 comments on commit 37aa46e

Please sign in to comment.