Skip to content

Commit 37aa46e

Browse files
committed
Fix config rewrite when exiting the app
1 parent 6d4c263 commit 37aa46e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

main.pyw

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ from PIL import Image
66
import os
77
import threading
88

9+
appIsRunning = True
10+
911

1012
class Const:
1113
CONFIG_FILE_PATH = "./config.txt"
@@ -87,10 +89,12 @@ def onIconRightClicked(stray, query):
8789
elif query == Const.STRAY_OPEN_CONFIG:
8890
openConfigFile()
8991
elif query == Const.STRAY_EXIT:
90-
config.en = False
91-
config.writeConfig()
92+
# config.en = False
93+
# config.writeConfig()
94+
global appIsRunning
95+
appIsRunning = False
9296
stray.stop()
93-
exit(0)
97+
# exit(0)
9498
config.writeConfig()
9599

96100

@@ -118,7 +122,7 @@ def setupStray():
118122
def main():
119123
config = Config()
120124
showSystemStatus(config)
121-
while True:
125+
while appIsRunning:
122126
battery = psutil.sensors_battery()
123127
isPluggedIn = battery.power_plugged
124128
if isPluggedIn:
@@ -129,7 +133,6 @@ def main():
129133
sendNotification("Low Battery, Plug-in charger", ("The Power is at " + str(battery.percent)))
130134
time.sleep(config.alertTimeInterval)
131135
config.readConfig()
132-
print('hey')
133136

134137

135138
def showSystemStatus(config: Config):

0 commit comments

Comments
 (0)