From b2d0979050cebab19f2d163dec0f9205f170f1c2 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Thu, 7 Sep 2017 05:10:47 +0200 Subject: [PATCH] [core/input] Ignore errors during callbacks If a callback command cannot be executed, do not terminate the whole bar. Furthermore, if such a failure occurs, try to fall back to a globally (i.e. non widget-specific) command, so that callbacks registered in the engine itself (such as mouse-wheel scrolling) still function properly. fixes #166 --- bumblebee/input.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bumblebee/input.py b/bumblebee/input.py index 1678b2e..cac471d 100644 --- a/bumblebee/input.py +++ b/bumblebee/input.py @@ -126,9 +126,14 @@ class I3BarInput(object): if cmd is None: return - if callable(cmd): - cmd(event) - else: - bumblebee.util.execute(cmd, False) + try: + if callable(cmd): + cmd(event) + else: + bumblebee.util.execute(cmd, False) + except Exception: + # fall back to global default + if not "__fallback" in event: + return self.callback({ "name": None, "instance": None, "__fallback": True, "button": event["button"] }) # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4