26 lines
774 B
Python
26 lines
774 B
Python
|
import psutil
|
||
|
import threading
|
||
|
import time
|
||
|
|
||
|
|
||
|
class PluginThread(threading.Thread):
|
||
|
def __init__(self, section, config, thread_id):
|
||
|
threading.Thread.__init__(self)
|
||
|
self.threadID = thread_id
|
||
|
self.status = dict()
|
||
|
if config.has_option(section, 'color'):
|
||
|
self.status['color'] = config.get(section, 'color')
|
||
|
self.freq = 1
|
||
|
|
||
|
def main(self):
|
||
|
mem_stat = psutil.virtual_memory()
|
||
|
mem_percentage = round(100.0 - mem_stat.percent, 2)
|
||
|
mem_available = round(mem_stat.available / 2**30, 2)
|
||
|
mem = 'RAM: ' + str(mem_percentage) + '% (' + str(mem_available) + 'G)'
|
||
|
self.status['full_text'] = mem
|
||
|
|
||
|
def run(self):
|
||
|
while True:
|
||
|
self.main()
|
||
|
time.sleep(self.freq)
|