diff --git a/core/decorators.py b/core/decorators.py index df555ff..6fcbf99 100644 --- a/core/decorators.py +++ b/core/decorators.py @@ -1,5 +1,12 @@ import util.format +def never(init): + def call_init(obj, *args, **kwargs): + init(obj, *args, **kwargs) + if obj.parameter('interval') is None: + obj.set('interval', 'never') + return call_init + def every(hours=0, minutes=0, seconds=0): def decorator_init(init): def call_init(obj, *args, **kwargs): diff --git a/core/output.py b/core/output.py index 9880531..fdb17a5 100644 --- a/core/output.py +++ b/core/output.py @@ -172,11 +172,14 @@ class i3(object): if affected_modules and not module.id in affected_modules: continue if not affected_modules and module.next_update: + if module.parameter('interval', '') == 'never': + continue if now < module.next_update: continue if not redraw_only: module.update_wrapper() - module.next_update = now + float(module.parameter('interval', self.__config.interval())) + if module.parameter('interval', '') != 'never': + module.next_update = now + float(module.parameter('interval', self.__config.interval())) for widget in module.widgets(): self.__content[widget] = widget.full_text() diff --git a/modules/contrib/xkcd.py b/modules/contrib/xkcd.py index 143e590..85a8713 100644 --- a/modules/contrib/xkcd.py +++ b/modules/contrib/xkcd.py @@ -2,16 +2,17 @@ """Opens a random xkcd comic in the browser.""" -import bumblebee.input -import bumblebee.output -import bumblebee.engine +import core.module +import core.widget +import core.input +import core.decorators +class Module(core.module.Module): + @core.decorators.never + def __init__(self, config): + super().__init__(config, core.widget.Widget('xkcd')) + core.input.register(self, button=core.input.LEFT_MOUSE, + cmd="xdg-open https://c.xkcd.com/random/comic/" + ) -class Module(bumblebee.engine.Module): - def __init__(self, engine, config): - super(Module, self).__init__(engine, config, - bumblebee.output.Widget(full_text="xkcd") - ) - engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE, - cmd="xdg-open https://c.xkcd.com/random/comic/" - ) +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4