From 7527cfcb480877bf95bb91676a6d04e479739239 Mon Sep 17 00:00:00 2001 From: ibrokemypie Date: Fri, 2 Jun 2017 00:29:09 +1000 Subject: [PATCH] [modules/memory] Add parameter to only show used memory No change to default behaviour, but adds boolean to only display used rather than used, total and percentage. To only show used memory: -p memory.usedonly=1 --- bumblebee/modules/memory.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bumblebee/modules/memory.py b/bumblebee/modules/memory.py index 0534f7d..ec55c8d 100644 --- a/bumblebee/modules/memory.py +++ b/bumblebee/modules/memory.py @@ -3,8 +3,9 @@ """Displays available RAM, total amount of RAM and percentage available. Parameters: - * cpu.warning : Warning threshold in % of memory used (defaults to 80%) - * cpu.critical: Critical threshold in % of memory used (defaults to 90%) + * ram.warning : Warning threshold in % of memory used (defaults to 80%) + * ram.critical: Critical threshold in % of memory used (defaults to 90%) + * ram.usedonly: Only show the amount of RAM in use. """ try: @@ -28,6 +29,8 @@ class Module(bumblebee.engine.Module): def memory_usage(self, widget): used = self._mem.total - self._mem.available + if bool(self.parameter("usedonly", 0)) == 1: + return bumblebee.util.bytefmt(used) return "{}/{} ({:05.02f}%)".format( bumblebee.util.bytefmt(used), bumblebee.util.bytefmt(self._mem.total),