From 08b5386140fb14ecbccdf9eb7520f597967dee4d Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Fri, 14 Jan 2022 13:39:04 +0100 Subject: [PATCH] [util/popup] fix endless loop on "close on leave" When closing a popup window when the mouse leave the area (default behaviour, unfortunately), the main "show()" got stuck in an infinite loop. Fix that by setting running to False when exiting. fixes #844 --- bumblebee_status/modules/contrib/arandr.py | 11 ++++++----- bumblebee_status/util/popup.py | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bumblebee_status/modules/contrib/arandr.py b/bumblebee_status/modules/contrib/arandr.py index fd9ad9e..b207524 100644 --- a/bumblebee_status/modules/contrib/arandr.py +++ b/bumblebee_status/modules/contrib/arandr.py @@ -54,7 +54,7 @@ class Module(core.module.Module): def activate_layout(layout_path): log.debug("activating layout") log.debug(layout_path) - execute(layout_path) + execute(layout_path, ignore_errors=True) def popup(self, widget): """Create Popup that allows the user to control their displays in one @@ -64,7 +64,7 @@ class Module(core.module.Module): menu = popup.menu() menu.add_menuitem( "arandr", - callback=partial(execute, self.manager) + callback=partial(execute, self.manager, ignore_errors=True) ) menu.add_separator() @@ -105,11 +105,12 @@ class Module(core.module.Module): if count_on == 1: log.info("attempted to turn off last display") return - execute("{} --output {} --off".format(self.toggle_cmd, display)) + execute("{} --output {} --off".format(self.toggle_cmd, display), ignore_errors=True) else: log.debug("toggling on {}".format(display)) execute( - "{} --output {} --auto".format(self.toggle_cmd, display) + "{} --output {} --auto".format(self.toggle_cmd, display), + ignore_errors=True ) @staticmethod @@ -120,7 +121,7 @@ class Module(core.module.Module): connected). """ displays = {} - for line in execute("xrandr -q").split("\n"): + for line in execute("xrandr -q", ignore_errors=True).split("\n"): if "connected" not in line: continue is_on = bool(re.search(r"\d+x\d+\+(\d+)\+\d+", line)) diff --git a/bumblebee_status/util/popup.py b/bumblebee_status/util/popup.py index bbabe66..784a037 100644 --- a/bumblebee_status/util/popup.py +++ b/bumblebee_status/util/popup.py @@ -49,6 +49,7 @@ class menu(object): return self._menu def __on_focus_out(self, event=None): + self.running = False self._root.destroy() def __on_click(self, callback):