[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.
This commit is contained in:
parent
2f0cc30c38
commit
73d62d7ded
2 changed files with 8 additions and 12 deletions
|
@ -33,7 +33,7 @@ class Module(bumblebee.module.Module):
|
||||||
|
|
||||||
def widgets(self):
|
def widgets(self):
|
||||||
return [
|
return [
|
||||||
bumblebee.output.Widget(
|
bumblebee.output.Widget(self,
|
||||||
datetime.datetime.now().strftime(self._fmt)
|
datetime.datetime.now().strftime(self._fmt)
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import inspect
|
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
def output(args):
|
def output(args):
|
||||||
|
@ -6,27 +5,24 @@ def output(args):
|
||||||
return bumblebee.outputs.i3.Output(args)
|
return bumblebee.outputs.i3.Output(args)
|
||||||
|
|
||||||
class Widget(object):
|
class Widget(object):
|
||||||
def __init__(self, text, warning=False, critical=False, state=None):
|
def __init__(self, obj, text):
|
||||||
self._name = inspect.getmodule(inspect.stack()[1][0]).__name__
|
self._obj = obj
|
||||||
self._text = text
|
self._text = text
|
||||||
self._warning = warning
|
|
||||||
self._critical = critical
|
|
||||||
self._state = state
|
|
||||||
|
|
||||||
def state(self):
|
def state(self):
|
||||||
return self._state
|
return self._obj.state()
|
||||||
|
|
||||||
def warning(self):
|
def warning(self):
|
||||||
return self._warning
|
return self._obj.warning()
|
||||||
|
|
||||||
def critical(self):
|
def critical(self):
|
||||||
return self._critical
|
return self._obj.critical()
|
||||||
|
|
||||||
def module(self):
|
def module(self):
|
||||||
return self._name.split(".")[-1]
|
return self._obj.__module__.split(".")[-1]
|
||||||
|
|
||||||
def name(self):
|
def name(self):
|
||||||
return self._name
|
return self._obj.__module__
|
||||||
|
|
||||||
def text(self):
|
def text(self):
|
||||||
return self._text
|
return self._text
|
||||||
|
|
Loading…
Reference in a new issue