Skip to content

Commit

Permalink
[util/popup] fix endless loop on "close on leave"
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tobi-wan-kenobi committed Jan 14, 2022
1 parent 8bde637 commit 08b5386
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 6 additions & 5 deletions bumblebee_status/modules/contrib/arandr.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self, config, theme):
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
Expand All @@ -64,7 +64,7 @@ def popup(self, widget):
menu = popup.menu()
menu.add_menuitem(
"arandr",
callback=partial(execute, self.manager)
callback=partial(execute, self.manager, ignore_errors=True)
)
menu.add_separator()

Expand Down Expand Up @@ -105,11 +105,12 @@ def toggle_display(self, display, current_state, count_on):
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
Expand All @@ -120,7 +121,7 @@ def _get_displays():
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))
Expand Down
1 change: 1 addition & 0 deletions bumblebee_status/util/popup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def menu(self):
return self._menu

def __on_focus_out(self, event=None):
self.running = False
self._root.destroy()

def __on_click(self, callback):
Expand Down

0 comments on commit 08b5386

Please sign in to comment.