From c617a478bff7e8026f0cba4b44b4e7af149c0881 Mon Sep 17 00:00:00 2001 From: Lucas Souto Date: Fri, 7 Sep 2018 22:21:57 -0300 Subject: [PATCH 1/5] Add module arch-update --- bumblebee/modules/arch-update.py | 41 ++++++++++++++++++++++++++++++++ themes/icons/awesome-fonts.json | 11 +++++---- 2 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 bumblebee/modules/arch-update.py diff --git a/bumblebee/modules/arch-update.py b/bumblebee/modules/arch-update.py new file mode 100644 index 0000000..7f290d8 --- /dev/null +++ b/bumblebee/modules/arch-update.py @@ -0,0 +1,41 @@ +"""Check updates to Arch Linux.""" + + +import subprocess +import bumblebee.input +import bumblebee.output +import bumblebee.engine + +class Module(bumblebee.engine.Module): + def __init__(self, engine, config): + widget = bumblebee.output.Widget(full_text=self.utilization) + super(Module, self).__init__(engine, config, widget) + self.packages = self.check_updates() + + def check_updates(self): + p = subprocess.Popen( + "checkupdates", stdout=subprocess.PIPE, shell=True) + + p_status = p.wait() + + if p_status == 0: + (output, err) = p.communicate() + + output = output.decode('utf-8') + packages = output.split('\n') + packages.pop() + + return len(packages) + return '0' + + def utilization(self, widget): + return f'Update Arch: {self.packages}' + + def hidden(self): + return self.check_updates() == 0 + + def update(self, widgets): + self.packages = self.check_updates() + + def state(self, widget): + return self.threshold_state(self.packages, 1, 100) diff --git a/themes/icons/awesome-fonts.json b/themes/icons/awesome-fonts.json index b9491da..8415de5 100644 --- a/themes/icons/awesome-fonts.json +++ b/themes/icons/awesome-fonts.json @@ -114,10 +114,13 @@ "repeat-on": { "prefix": "" }, "repeat-off": { "prefix": "" } }, - "github": { - "prefix": "  " - }, - "hipchat": { + "arch": { + "prefix": "" + }, + "github": { + "prefix": "  " + }, + "hipchat": { "prefix": "  " }, "spotify": { From 39233e5a754da45793f562a1659a0187dfbcc9fd Mon Sep 17 00:00:00 2001 From: Lucas Souto Date: Fri, 7 Sep 2018 22:29:51 -0300 Subject: [PATCH 2/5] Fix icon arch-update --- themes/icons/awesome-fonts.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/icons/awesome-fonts.json b/themes/icons/awesome-fonts.json index b6ca8d7..ad8d07a 100644 --- a/themes/icons/awesome-fonts.json +++ b/themes/icons/awesome-fonts.json @@ -117,7 +117,7 @@ "repeat-on": { "prefix": "" }, "repeat-off": { "prefix": "" } }, - "arch": { + "arch-update": { "prefix": "" }, "github": { From edee95b57a1bf4b03b8f27cd67436e29a3b87209 Mon Sep 17 00:00:00 2001 From: Lucas Souto Date: Fri, 7 Sep 2018 22:38:15 -0300 Subject: [PATCH 3/5] Fix code for lint --- bumblebee/modules/arch-update.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bumblebee/modules/arch-update.py b/bumblebee/modules/arch-update.py index 7f290d8..26215c6 100644 --- a/bumblebee/modules/arch-update.py +++ b/bumblebee/modules/arch-update.py @@ -6,6 +6,7 @@ import bumblebee.input import bumblebee.output import bumblebee.engine + class Module(bumblebee.engine.Module): def __init__(self, engine, config): widget = bumblebee.output.Widget(full_text=self.utilization) @@ -17,7 +18,7 @@ class Module(bumblebee.engine.Module): "checkupdates", stdout=subprocess.PIPE, shell=True) p_status = p.wait() - + if p_status == 0: (output, err) = p.communicate() @@ -35,7 +36,7 @@ class Module(bumblebee.engine.Module): return self.check_updates() == 0 def update(self, widgets): - self.packages = self.check_updates() + self.packages = self.check_updates() def state(self, widget): return self.threshold_state(self.packages, 1, 100) From 63bb771df22c73d2e45e6577a01bf4e4a7c60dc6 Mon Sep 17 00:00:00 2001 From: lucassouto Date: Sat, 8 Sep 2018 18:59:55 -0300 Subject: [PATCH 4/5] Fix for previous versions of python --- bumblebee/modules/arch-update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bumblebee/modules/arch-update.py b/bumblebee/modules/arch-update.py index 26215c6..8df8b13 100644 --- a/bumblebee/modules/arch-update.py +++ b/bumblebee/modules/arch-update.py @@ -30,7 +30,7 @@ class Module(bumblebee.engine.Module): return '0' def utilization(self, widget): - return f'Update Arch: {self.packages}' + return 'Update Arch: {}'.format(self.packages) def hidden(self): return self.check_updates() == 0 From 2b8dbf6bc623d0a95efdf0a5fbb3ee0f2a541560 Mon Sep 17 00:00:00 2001 From: lucassouto Date: Sat, 8 Sep 2018 19:06:28 -0300 Subject: [PATCH 5/5] Add pacman-contrib in required modules --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3232b17..b989614 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,7 @@ Modules and commandline utilities are only required for modules, the core itself * power (for the module 'battery') * dbus (for the module 'spotify') * i3ipc (for the module 'title') +* pacman-contrib (for module 'arch-update') # Required commandline utilities