From 25054685154c76b79f1b30c298964c6530c6b3a7 Mon Sep 17 00:00:00 2001 From: ncoop Date: Wed, 22 Jun 2016 23:57:40 -0700 Subject: [PATCH] Notification support for aptget. --- i3pystatus/updates/aptget.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/i3pystatus/updates/aptget.py b/i3pystatus/updates/aptget.py index f73c733..432f520 100644 --- a/i3pystatus/updates/aptget.py +++ b/i3pystatus/updates/aptget.py @@ -23,10 +23,14 @@ class AptGet(Backend): command = "apt-get upgrade -s -o Dir::State::Lists=" + cache_dir apt = run_through_shell(command.split()) - update_count = 0 - for line in apt.out.split("\n"): - if line.startswith("Inst"): - update_count += 1 - return update_count + out = apt.out.splitlines() + out = [line[5:] for line in apt.out if line.startswith("Inst ")] + return out.count("\n"), out Backend = AptGet + +if __name__ == "__main__": + """ + Call this module directly; Print the update count and notification body. + """ + print("Updates: {}\n\n{}".format(*Backend().updates))