vdstatus/plugins/pacman.py

24 lines
754 B
Python
Raw Normal View History

import plugins
import subprocess
class PluginThread(plugins.PluginThreadCommon):
def __init__(self, section, config):
super(PluginThread, self).__init__(section, config)
2017-01-13 12:36:09 +02:00
self.freq = config.getint(section, 'freq', fallback=15)
self.format_status(0)
def format_status(self, count):
self.status['full_text'] = 'UPD: ' + str(count)
if count > 0:
self.hide = False
2017-01-13 10:22:08 +02:00
self.status['urgent'] = True
else:
self.hide = True
2017-01-13 10:22:08 +02:00
self.status['urgent'] = False
def main(self):
# TODO: this is an ugly hack, fix it with subprocess.Popen asap
updates = subprocess.getoutput('/usr/bin/pacman -Qu').count(" -> ")
self.format_status(updates)