Browse Source

disk and load plugins, freq option support for all plugins

master
Von Random 6 years ago
parent
commit
b839f9f114
  1. 2
      plugins/batt.py
  2. 2
      plugins/date.py
  3. 26
      plugins/disk.py
  4. 24
      plugins/load.py
  5. 7
      plugins/mem.py

2
plugins/batt.py

@ -12,7 +12,7 @@ class PluginThread(threading.Thread):
self.status = dict()
if config.has_option(section, 'color'):
self.status['color'] = config.get(section, 'color')
self.freq = 1
self.freq = config.get(section, 'freq', fallback=1)
def main(self):
with open(BATTERY_DIR + 'capacity', 'r') as capacity, \

2
plugins/date.py

@ -10,7 +10,7 @@ class PluginThread(threading.Thread):
self.status = dict()
if config.has_option(section, 'color'):
self.status['color'] = config.get(section, 'color')
self.freq = 1
self.freq = config.get(section, 'freq', fallback=1)
def main(self):
self.status['full_text'] = time.strftime(self.date_format)

26
plugins/disk.py

@ -0,0 +1,26 @@
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()
self.part = config.get(section, 'part')
if config.has_option(section, 'color'):
self.status['color'] = config.get(section, 'color')
self.freq = config.getint(section, 'freq', fallback=30)
def main(self):
du_stat = psutil.disk_usage(self.part)
# du_perc = str(du_stat.percent)
du_free = str(round(du_stat.free / 2**30, 2))
du = self.part + ': ' + du_free + 'G'
self.status['full_text'] = du
def run(self):
while True:
self.main()
time.sleep(self.freq)

24
plugins/load.py

@ -0,0 +1,24 @@
import os
import time
import threading
class PluginThread(threading.Thread):
def __init__(self, section, config, thread_id):
threading.Thread.__init__(self)
self.threadID = thread_id
self.date_format = config.get(section, 'format', fallback='%c')
self.status = dict()
if config.has_option(section, 'color'):
self.status['color'] = config.get(section, 'color')
self.freq = config.get(section, 'freq', fallback=10)
def main(self):
loads = os.getloadavg()
loads = [str(i) for i in loads]
self.status['full_text'] = 'LA: ' + ' '.join(loads)
def run(self):
while True:
self.main()
time.sleep(self.freq)

7
plugins/mem.py

@ -10,13 +10,12 @@ class PluginThread(threading.Thread):
self.status = dict()
if config.has_option(section, 'color'):
self.status['color'] = config.get(section, 'color')
self.freq = 1
self.freq = config.get(section, 'freq', fallback=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)'
mem_available = str(round(mem_stat.available / 2**30, 2))
mem = 'RAM: ' + mem_available + 'G'
self.status['full_text'] = mem
def run(self):

Loading…
Cancel
Save