plugins: allow disabling of title field; pacman: rename to cmd; cmd: use first line of output as value, not line count

This commit is contained in:
Von Random 2019-10-28 11:57:51 +03:00
parent d824345ba1
commit b03a588182
2 changed files with 5 additions and 11 deletions

View file

@ -18,7 +18,7 @@ class PluginThreadCommon:
self.thread.daemon = True
def format_status(self, status, urgent=False):
if 'title' in self.conf:
if 'title' in self.conf and self.conf['title']:
full_text = '{}: {}'.format(self.conf['title'], status)
else:
full_text = status

View file

@ -3,8 +3,8 @@ import subprocess
PACMAN_DEFAULTS = {
'cmd': ('/usr/bin/pacman', '-Qu'),
'title': 'UPD', 'freq': 15, 'problem': 10
'cmd': ('/usr/bin/echo', 'I am cmd'),
'title': 'CMD', 'freq': 15
}
@ -18,12 +18,6 @@ class PluginThread(plugins.PluginThreadCommon):
stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL,
encoding='UTF-8'
)
out = pacman_qu.communicate()[0].strip().splitlines()
packages = len([pkg for pkg in out if not '[ignored]' in pkg])
if packages:
self.hide = False
else:
self.hide = True
out = pacman_qu.communicate()[0].strip().splitlines()[0]
urgent = packages >= self.conf['problem']
self.format_status(packages, urgent)
self.format_status(out)