diff --git a/core/module.py b/core/module.py index a2c0f3b..a68d072 100644 --- a/core/module.py +++ b/core/module.py @@ -12,6 +12,15 @@ except Exception as e: log = logging.getLogger(__name__) +def every(minutes=0, seconds=0): + def decorator_init(init): + def call_init(obj, *args, **kwargs): + init(obj, *args, **kwargs) + if obj.parameter('interval') is None: + obj.set('interval', minutes*60 + seconds) + return call_init + return decorator_init + def load(module_name, config=None): error = None for namespace in [ 'core', 'contrib' ]: diff --git a/doc/HOWTO_MODULE.md b/doc/HOWTO_MODULE.md index fee9ed8..dde0210 100644 --- a/doc/HOWTO_MODULE.md +++ b/doc/HOWTO_MODULE.md @@ -35,3 +35,11 @@ class Module(core.module.Module): # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 ``` + +## `update` vs. `full_text` +TODO + +## TODOs +- default update interval +- scrolling +- diff --git a/modules/core/kernel.py b/modules/core/kernel.py index 3e0dbf7..c70c7f6 100644 --- a/modules/core/kernel.py +++ b/modules/core/kernel.py @@ -8,6 +8,7 @@ import core.module import core.widget class Module(core.module.Module): + @core.module.every(minutes=60) def __init__(self, config=None): super().__init__(config, core.widget.Widget(self.full_text))