2017-01-12 15:56:32 +02:00
|
|
|
import plugins
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
|
2019-03-28 12:21:15 +02:00
|
|
|
PACMAN_DEFAULTS = {
|
|
|
|
'cmd': ('/usr/bin/pacman', '-Qu'),
|
|
|
|
'title': 'UPD', 'freq': 15, 'problem': 10
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-12 15:56:32 +02:00
|
|
|
class PluginThread(plugins.PluginThreadCommon):
|
2017-12-16 01:55:28 +02:00
|
|
|
def __init__(self, config):
|
2019-03-28 12:21:15 +02:00
|
|
|
super(PluginThread, self).__init__(config, PACMAN_DEFAULTS)
|
2017-01-12 15:56:32 +02:00
|
|
|
|
|
|
|
def main(self):
|
2019-01-16 13:46:52 +02:00
|
|
|
pacman_qu = subprocess.Popen(
|
2019-03-21 14:17:38 +02:00
|
|
|
self.conf['cmd'], stdout=subprocess.PIPE,
|
2019-02-28 18:00:49 +02:00
|
|
|
stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL,
|
|
|
|
encoding='UTF-8'
|
2019-01-16 13:46:52 +02:00
|
|
|
)
|
2019-01-31 13:19:43 +02:00
|
|
|
out = pacman_qu.communicate()[0].strip().splitlines()
|
2019-07-05 18:24:46 +03:00
|
|
|
packages = len([pkg for pkg in out if not '[ignored]' in pkg])
|
|
|
|
if packages:
|
|
|
|
self.hide = False
|
|
|
|
else:
|
|
|
|
self.hide = True
|
2019-07-08 14:19:05 +03:00
|
|
|
|
|
|
|
urgent = packages >= self.conf['problem']
|
|
|
|
self.format_status(packages, urgent)
|