Browse Source

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

master
Von Random 6 years ago
parent
commit
68f268d7c2
  1. 4
      plugins/batt.py
  2. 1
      plugins/date.py
  3. 1
      plugins/disk.py
  4. 1
      plugins/load.py
  5. 1
      plugins/mem.py
  6. 15
      plugins/ping.py
  7. 3
      vdstatus

4
plugins/batt.py

@ -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

1
plugins/date.py

@ -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)

1
plugins/disk.py

@ -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)

1
plugins/load.py

@ -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()

1
plugins/mem.py

@ -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()

15
plugins/ping.py

@ -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)

3
vdstatus

@ -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)

Loading…
Cancel
Save