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 self.thread.daemon = True
def format_status(self, status, urgent=False): 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) full_text = '{}: {}'.format(self.conf['title'], status)
else: else:
full_text = status full_text = status

View file

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