replace colors with urgency status + add means to hide unimportant measures; TODO: configurabilty of hiding

This commit is contained in:
Von Random 2016-10-25 19:48:40 +03:00
parent 16706a5d5f
commit 68f268d7c2
7 changed files with 16 additions and 10 deletions

View file

@ -13,6 +13,7 @@ class PluginThread(threading.Thread):
if config.has_option(section, 'color'):
self.status['color'] = config.get(section, 'color')
self.freq = config.getint(section, 'freq', fallback=1)
self.hide = False
def main(self):
with open(BATTERY_DIR + 'capacity', 'r') as capacity, \
@ -21,8 +22,11 @@ class PluginThread(threading.Thread):
batt_capacity = capacity.read().strip()
if batt_stat != 'Discharging':
batt_stat = '\u2191'
if float(batt_capacity) < 15:
self.status['urgent'] = True
else:
batt_stat = '\u2193'
batt = 'BAT: ' + batt_capacity + '% ' + batt_stat
self.status['full_text'] = batt

View file

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

View file

@ -12,6 +12,7 @@ class PluginThread(threading.Thread):
if config.has_option(section, 'color'):
self.status['color'] = config.get(section, 'color')
self.freq = config.getint(section, 'freq', fallback=30)
self.hide = False
def main(self):
du_stat = psutil.disk_usage(self.part)

View file

@ -12,6 +12,7 @@ class PluginThread(threading.Thread):
if config.has_option(section, 'color'):
self.status['color'] = config.get(section, 'color')
self.freq = config.getint(section, 'freq', fallback=10)
self.hide = False
def main(self):
loads = os.getloadavg()

View file

@ -11,6 +11,7 @@ class PluginThread(threading.Thread):
if config.has_option(section, 'color'):
self.status['color'] = config.get(section, 'color')
self.freq = config.getint(section, 'freq', fallback=1)
self.hide = False
def main(self):
mem_stat = psutil.virtual_memory()

View file

@ -10,22 +10,19 @@ class PluginThread(threading.Thread):
self.threadID = thread_id
self.hosts = config.get(section, 'hosts').split(',')
self.title = config.get(section, 'title')
if config.has_option(section, 'colors'):
self.colors = config.get(section, 'colors').split(',')
else:
self.colors = None
self.timeout = config.get(section, 'timeout', fallback='150')
self.status = dict()
self.freq = config.getint(section, 'freq', fallback=5)
self.format_status('n/a')
self.hide = False
def format_status(self, state):
self.status['full_text'] = self.title + ': ' + state
if self.colors is not None:
if state == 'on':
self.status['color'] = self.colors[0]
else:
self.status['color'] = self.colors[1]
if state == 'on':
self.status['urgent'] = False
self.hide = True
else:
self.status['urgent'] = True
def main(self):
random.shuffle(self.hosts)

View file

@ -70,7 +70,8 @@ def run_plugins(config_file=DEFAULT_CONFIG):
while True:
outputs = list()
for plugin in plugins_l:
outputs.append(plugin.status)
if plugin.hide == False:
outputs.append(plugin.status)
print(format_outputs(outputs))
time.sleep(1)