diff options
author | Von Random <von@vdrandom.org> | 2019-10-28 11:57:51 +0300 |
---|---|---|
committer | Von Random <von@vdrandom.org> | 2019-10-28 11:57:51 +0300 |
commit | b03a5881825ddf3f9f5831342a9bf61ed3a4970e (patch) | |
tree | e420d49342b0e32a36d51fbb0b73897637da7fc3 | |
parent | d824345ba1e184b3e3e1e71aa2fd91fb292eb93c (diff) |
plugins: allow disabling of title field; pacman: rename to cmd; cmd: use first line of output as value, not line count
-rw-r--r-- | plugins/__init__.py | 2 | ||||
-rw-r--r-- | plugins/cmd.py (renamed from plugins/pacman.py) | 14 |
2 files changed, 5 insertions, 11 deletions
diff --git a/plugins/__init__.py b/plugins/__init__.py index 016b462..262d144 100644 --- a/plugins/__init__.py +++ b/plugins/__init__.py @@ -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 diff --git a/plugins/pacman.py b/plugins/cmd.py index 2b4551f..839dffe 100644 --- a/plugins/pacman.py +++ b/plugins/cmd.py @@ -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) |