diff --git a/bumblebee/modules/load.py b/bumblebee/modules/load.py new file mode 100644 index 0000000..fba5dbd --- /dev/null +++ b/bumblebee/modules/load.py @@ -0,0 +1,37 @@ +import bumblebee.module +import multiprocessing +import os + +def description(): + return "Displays system load." + +def parameters(): + return [ + "load.warning: Warning threshold for the one-minute load average (defaults to 70% of the number of CPUs)", + "load.critical: Critical threshold for the one-minute load average (defaults 80% of the number of CPUs)" + ] + +class Module(bumblebee.module.Module): + def __init__(self, output, config, alias): + super(Module, self).__init__(output, config, alias) + self._cpus = 1 + try: + self._cpus = multiprocessing.cpu_count() + except multiprocessing.NotImplementedError as e: + pass + + output.add_callback(module=self.instance(), button=1, cmd="gnome-system-monitor") + + def widgets(self): + self._load = os.getloadavg() + + return bumblebee.output.Widget(self, "{:.02f}/{:.02f}/{:.02f}".format( + self._load[0], self._load[1], self._load[2])) + + def warning(self, widget): + return self._load[0] > self._config.parameter("warning", self._cpus*0.7) + + def critical(self, widget): + return self._load[0] > self._config.parameter("critical", self._cpus*0.8) + +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 diff --git a/screenshots/load.png b/screenshots/load.png new file mode 100644 index 0000000..8ed7bd6 Binary files /dev/null and b/screenshots/load.png differ diff --git a/themes/default.json b/themes/default.json index 32a23ea..5c9498a 100644 --- a/themes/default.json +++ b/themes/default.json @@ -17,6 +17,9 @@ "cpu": { "prefix": " cpu " }, + "load": { + "prefix": " load " + }, "disk": { "prefix": " hdd " }, diff --git a/themes/gruvbox-powerline.json b/themes/gruvbox-powerline.json index 1f3271b..ba155e0 100644 --- a/themes/gruvbox-powerline.json +++ b/themes/gruvbox-powerline.json @@ -33,6 +33,9 @@ "cpu": { "prefix": "  " }, + "load": { + "prefix": "  " + }, "disk": { "prefix": "  " }, diff --git a/themes/powerline.json b/themes/powerline.json index 84fb73a..d74c461 100644 --- a/themes/powerline.json +++ b/themes/powerline.json @@ -32,6 +32,9 @@ "cpu": { "prefix": "  " }, + "load": { + "prefix": "  " + }, "disk": { "prefix": "  " }, diff --git a/themes/solarized-powerline.json b/themes/solarized-powerline.json index 5cbd561..206e030 100644 --- a/themes/solarized-powerline.json +++ b/themes/solarized-powerline.json @@ -33,6 +33,9 @@ "cpu": { "prefix": "  " }, + "load": { + "prefix": "  " + }, "disk": { "prefix": "  " }, diff --git a/themes/solarized.json b/themes/solarized.json index af6d876..8a3fc8f 100644 --- a/themes/solarized.json +++ b/themes/solarized.json @@ -32,6 +32,9 @@ "cpu": { "prefix": " cpu " }, + "load": { + "prefix": " load " + }, "disk": { "prefix": " hdd " },