diff options
author | Von Random <von@vdrandom.org> | 2019-01-16 14:46:52 +0300 |
---|---|---|
committer | Von Random <von@vdrandom.org> | 2019-01-16 14:46:52 +0300 |
commit | 6fc4d3176de95cabebd826b6942f8612b0083dec (patch) | |
tree | 03983354b4f27e068df1a43fc92139043bef9f25 | |
parent | 27160d61bda59d7112786d933774ed0ba446bd50 (diff) |
replace an ugly hack with a proper subprocess.Popen() in the pacman plugin
-rw-r--r-- | plugins/pacman.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/plugins/pacman.py b/plugins/pacman.py index 7a9586c..148db8c 100644 --- a/plugins/pacman.py +++ b/plugins/pacman.py @@ -9,14 +9,21 @@ class PluginThread(plugins.PluginThreadCommon): 'problem': 10 } super(PluginThread, self).__init__(config, defaults) - self.format_status(0) + self.format_status(list()) - def format_status(self, count): - self.status['full_text'] = 'UPD: ' + str(count) + def format_status(self, updates): + count = int() + for update in updates: + if not '[ignored]' in update: + count += 1 self.hide = count == 0 self.status['urgent'] = count >= self.conf['problem'] + self.status['full_text'] = 'UPD: ' + str(count) def main(self): - # TODO: this is an ugly hack, fix it with subprocess.Popen someday - updates = subprocess.getoutput('/usr/bin/pacman -Qu').count(" -> ") - self.format_status(updates) + pacman_qu = subprocess.Popen( + ('/usr/bin/pacman', '-Qu'), stdout=subprocess.PIPE, + stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL + ) + out = str(pacman_qu.communicate()[0]) + self.format_status(out.splitlines()) |