[core] Add per-module interval configuration
Allow individual modules to set different update intervals by using an overriding 'interval' parameter. see #574
This commit is contained in:
parent
0e538a6088
commit
e8288ef793
2 changed files with 6 additions and 0 deletions
|
@ -36,6 +36,7 @@ class Module(core.input.Object):
|
||||||
for widget in self._widgets:
|
for widget in self._widgets:
|
||||||
widget.module(self)
|
widget.module(self)
|
||||||
self._name = None
|
self._name = None
|
||||||
|
self.next_update = None
|
||||||
|
|
||||||
def parameter(self, key, default=None):
|
def parameter(self, key, default=None):
|
||||||
value = default
|
value = default
|
||||||
|
|
|
@ -102,10 +102,15 @@ class i3(object):
|
||||||
return widgets
|
return widgets
|
||||||
|
|
||||||
def update(self, affected_modules=None):
|
def update(self, affected_modules=None):
|
||||||
|
now = time.time()
|
||||||
for module in self._modules:
|
for module in self._modules:
|
||||||
if affected_modules and not module.id() in affected_modules:
|
if affected_modules and not module.id() in affected_modules:
|
||||||
continue
|
continue
|
||||||
|
if not affected_modules and module.next_update:
|
||||||
|
if now < module.next_update:
|
||||||
|
continue
|
||||||
module.update_wrapper()
|
module.update_wrapper()
|
||||||
|
module.next_update = now + float(module.parameter('interval', self._config.interval()))
|
||||||
for widget in module.widgets():
|
for widget in module.widgets():
|
||||||
self._status[widget] = widget.full_text()
|
self._status[widget] = widget.full_text()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue