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 = {
|
2019-03-21 14:17:38 +02:00
|
|
|
'cmd': ('/usr/bin/pacman', '-Qu'),
|
|
|
|
'title': 'UPD',
|
2018-04-28 19:40:10 +03:00
|
|
|
'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-03-21 14:17:38 +02:00
|
|
|
self.status['full_text'] = self.conf['title'] + ': ' + 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(
|
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()
|
|
|
|
packages = [pkg for pkg in out if not '[ignored]' in pkg]
|
|
|
|
self.format_status(len(packages))
|