bumblebee-status/modules/contrib/uptime.py

26 lines
630 B
Python
Raw Normal View History

2020-04-13 09:29:16 +02:00
# pylint: disable=C0111,R0903
"""Displays the system uptime."""
from datetime import timedelta
2020-04-13 09:32:29 +02:00
import core.module
import core.widget
2020-04-13 09:32:29 +02:00
class Module(core.module.Module):
def __init__(self, config, theme):
super().__init__(config, theme, core.widget.Widget(self.output))
self.__uptime = ""
2020-04-13 09:29:16 +02:00
def output(self, _):
return "{}".format(self.__uptime)
2020-04-13 09:29:16 +02:00
2020-04-13 09:32:29 +02:00
def update(self):
with open("/proc/uptime", "r") as f:
2020-04-13 09:29:16 +02:00
uptime_seconds = int(float(f.readline().split()[0]))
self.__uptime = timedelta(seconds=uptime_seconds)
2020-04-13 09:29:16 +02:00
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4