diff --git a/bumblebee/modules/uptime.py b/bumblebee/modules/uptime.py new file mode 100644 index 0000000..e7e68c9 --- /dev/null +++ b/bumblebee/modules/uptime.py @@ -0,0 +1,26 @@ +# pylint: disable=C0111,R0903 + +"""Displays the system uptime.""" + +import bumblebee.input +import bumblebee.output +import bumblebee.engine + +from datetime import timedelta + +class Module(bumblebee.engine.Module): + def __init__(self, engine, config): + super(Module, self).__init__(engine, config, + bumblebee.output.Widget(full_text=self.output) + ) + self._uptime = "" + + def output(self, _): + return "{}".format(self._uptime) + + def update(self, widgets): + with open('/proc/uptime', 'r') as f: + uptime_seconds = int(float(f.readline().split()[0])) + self._uptime = timedelta(seconds = uptime_seconds) + +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 diff --git a/themes/icons/ascii.json b/themes/icons/ascii.json index ca7be0e..347fcfd 100644 --- a/themes/icons/ascii.json +++ b/themes/icons/ascii.json @@ -86,5 +86,8 @@ }, "spotify": { "prefix": "" + }, + "uptime": { + "prefix": "uptime" } } diff --git a/themes/icons/awesome-fonts.json b/themes/icons/awesome-fonts.json index 4628828..f8bd8cc 100644 --- a/themes/icons/awesome-fonts.json +++ b/themes/icons/awesome-fonts.json @@ -16,7 +16,8 @@ "layout": { "prefix": "" }, "layout-xkb": { "prefix": "" }, "todo": { "empty": {"prefix": "" }, - "items": {"prefix": "" } + "items": {"prefix": "" }, + "uptime": {"prefix": "" } }, "cmus": {