2017-01-12 15:56:32 +02:00
|
|
|
import plugins
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
|
|
|
|
class PluginThread(plugins.PluginThreadCommon):
|
2017-12-16 01:55:28 +02:00
|
|
|
def __init__(self, config):
|
2018-04-28 19:40:10 +03:00
|
|
|
defaults = {
|
|
|
|
'freq': 15,
|
|
|
|
'problem': 10
|
|
|
|
}
|
2017-12-16 01:55:28 +02:00
|
|
|
super(PluginThread, self).__init__(config, defaults)
|
2019-01-31 13:19:43 +02:00
|
|
|
self.format_status(0)
|
2017-01-12 15:56:32 +02:00
|
|
|
|
2019-01-31 13:19:43 +02:00
|
|
|
def format_status(self, count):
|
2018-04-28 19:40:10 +03:00
|
|
|
self.hide = count == 0
|
|
|
|
self.status['urgent'] = count >= self.conf['problem']
|
2019-01-16 13:46:52 +02:00
|
|
|
self.status['full_text'] = 'UPD: ' + str(count)
|
2017-01-12 15:56:32 +02:00
|
|
|
|
|
|
|
def main(self):
|
2019-01-16 13:46:52 +02:00
|
|
|
pacman_qu = subprocess.Popen(
|
|
|
|
('/usr/bin/pacman', '-Qu'), stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL
|
|
|
|
)
|
2019-01-31 13:19:43 +02:00
|
|
|
out = pacman_qu.communicate()[0].strip().splitlines()
|
|
|
|
packages = [pkg for pkg in out if not '[ignored]' in pkg]
|
|
|
|
self.format_status(len(packages))
|