From 73d62d7dedbfeddb0339b61292392ec6142f38f7 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Sat, 5 Nov 2016 12:14:33 +0100 Subject: [PATCH] [widgets] Pass through some information to the underlying module object For determining status, critical/warning state, etc. simply let the widget pass through a call to the underlying object. --- bumblebee/modules/time.py | 2 +- bumblebee/output.py | 18 +++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/bumblebee/modules/time.py b/bumblebee/modules/time.py index 60f2272..38e42d9 100644 --- a/bumblebee/modules/time.py +++ b/bumblebee/modules/time.py @@ -33,7 +33,7 @@ class Module(bumblebee.module.Module): def widgets(self): return [ - bumblebee.output.Widget( + bumblebee.output.Widget(self, datetime.datetime.now().strftime(self._fmt) ) ] diff --git a/bumblebee/output.py b/bumblebee/output.py index 4d8df8f..143439a 100644 --- a/bumblebee/output.py +++ b/bumblebee/output.py @@ -1,4 +1,3 @@ -import inspect import threading def output(args): @@ -6,27 +5,24 @@ def output(args): return bumblebee.outputs.i3.Output(args) class Widget(object): - def __init__(self, text, warning=False, critical=False, state=None): - self._name = inspect.getmodule(inspect.stack()[1][0]).__name__ + def __init__(self, obj, text): + self._obj = obj self._text = text - self._warning = warning - self._critical = critical - self._state = state def state(self): - return self._state + return self._obj.state() def warning(self): - return self._warning + return self._obj.warning() def critical(self): - return self._critical + return self._obj.critical() def module(self): - return self._name.split(".")[-1] + return self._obj.__module__.split(".")[-1] def name(self): - return self._name + return self._obj.__module__ def text(self): return self._text