some primitive exit handling, still have to do something about waiting till the longest freq value is reached

This commit is contained in:
Von Random 2016-11-18 18:42:28 +03:00
parent 9db9a935d4
commit 49d14d410a
7 changed files with 74 additions and 19 deletions

View file

@ -14,6 +14,7 @@ class PluginThread(threading.Thread):
self.status['color'] = config.get(section, 'color')
self.freq = config.getint(section, 'freq', fallback=1)
self.hide = False
self.should_stop = False
def main(self):
with open(BATTERY_DIR + 'capacity', 'r') as capacity, \
@ -34,7 +35,13 @@ class PluginThread(threading.Thread):
self.status['full_text'] = batt
def stop(self):
self.should_stop = True
def run(self):
while True:
self.main()
time.sleep(self.freq)
if self.should_stop is False:
self.main()
time.sleep(self.freq)
else:
break

View file

@ -12,11 +12,18 @@ class PluginThread(threading.Thread):
self.status['color'] = config.get(section, 'color')
self.freq = config.getint(section, 'freq', fallback=1)
self.hide = False
self.should_stop = False
def main(self):
self.status['full_text'] = time.strftime(self.date_format)
def stop(self):
self.should_stop = True
def run(self):
while True:
self.main()
time.sleep(self.freq)
if self.should_stop is False:
self.main()
time.sleep(self.freq)
else:
break

View file

@ -13,6 +13,7 @@ class PluginThread(threading.Thread):
self.status['color'] = config.get(section, 'color')
self.freq = config.getint(section, 'freq', fallback=30)
self.hide = False
self.should_stop = False
self.problem_value = config.getint(section, 'problem', fallback=70)
def main(self):
@ -27,7 +28,13 @@ class PluginThread(threading.Thread):
du = self.part + ': ' + du_free + 'G'
self.status['full_text'] = du
def stop(self):
self.should_stop = True
def run(self):
while True:
self.main()
time.sleep(self.freq)
if self.should_stop is False:
self.main()
time.sleep(self.freq)
else:
break

View file

@ -14,6 +14,7 @@ class PluginThread(threading.Thread):
self.freq = config.getint(section, 'freq', fallback=10)
self.hide_ok = config.getboolean(section, 'hide_ok', fallback=False)
self.hide = False
self.should_stop = False
self.problem_value = config.getint(section, 'problem', fallback=100)
def main(self):
@ -27,7 +28,13 @@ class PluginThread(threading.Thread):
loads = [str(i) for i in loads]
self.status['full_text'] = 'LA: ' + ' '.join(loads)
def stop(self):
self.should_stop = True
def run(self):
while True:
self.main()
time.sleep(self.freq)
if self.should_stop is False:
self.main()
time.sleep(self.freq)
else:
break

View file

@ -12,6 +12,7 @@ class PluginThread(threading.Thread):
self.status['color'] = config.get(section, 'color')
self.freq = config.getint(section, 'freq', fallback=1)
self.hide = False
self.should_stop = False
def main(self):
mem_stat = psutil.virtual_memory()
@ -19,7 +20,13 @@ class PluginThread(threading.Thread):
mem = 'RAM: ' + mem_available + 'G'
self.status['full_text'] = mem
def stop(self):
self.should_stop = True
def run(self):
while True:
self.main()
time.sleep(self.freq)
if self.should_stop is False:
self.main()
time.sleep(self.freq)
else:
break

View file

@ -15,6 +15,7 @@ class PluginThread(threading.Thread):
self.freq = config.getint(section, 'freq', fallback=5)
self.format_status('n/a')
self.hide = False
self.should_stop = False
def format_status(self, state):
self.status['full_text'] = self.title + ': ' + state
@ -34,7 +35,20 @@ class PluginThread(threading.Thread):
break
self.format_status('off')
def sleep(self):
seconds = 0
while seconds < self.freq:
time.sleep(1)
seconds += 1
del seconds
def stop(self):
self.should_stop = True
def run(self):
while True:
self.main()
time.sleep(self.freq)
if self.should_stop is False:
self.main()
self.sleep()
else:
break