Skip to content

Commit

Permalink
fix: restore and fix refresh_triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
friday committed Apr 16, 2024
1 parent dc0aefb commit 88832b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ulauncher/modes/ModeHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
_logger = logging.getLogger()
_events = EventBus("mode")
_modes: list[BaseMode] = []
_triggers: list[Result] = []


def get_modes() -> list[BaseMode]:
Expand Down Expand Up @@ -65,13 +66,15 @@ def get_mode_from_query(query: Query) -> BaseMode | None:
return None


def search(query: Query, min_score: int = 50, limit: int = 50) -> list[Result]:
searchables: list[Result] = []
def refresh_triggers() -> None:
_triggers.clear()
for mode in get_modes():
searchables.extend([*mode.get_triggers()])
_triggers.extend([*mode.get_triggers()])


def search(query: Query, min_score: int = 50, limit: int = 50) -> list[Result]:
# Cast apps to AppResult objects. Default apps to Gio.DesktopAppInfo.get_all()
sorted_ = sorted(searchables, key=lambda i: i.search_score(query), reverse=True)[:limit]
sorted_ = sorted(_triggers, key=lambda i: i.search_score(query), reverse=True)[:limit]
return list(filter(lambda searchable: searchable.search_score(query) > min_score, sorted_))


Expand Down
1 change: 1 addition & 0 deletions ulauncher/ui/windows/UlauncherWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ def position_window(self) -> None:
self.move(pos_x, pos_y)

def show(self) -> None:
ModeHandler.refresh_triggers()
self.present()
# note: present_with_time is needed on some DEs to defeat focus stealing protection
# (Gnome 3 forks like Cinnamon or Budgie, but not Gnome 3 itself any longer)
Expand Down

0 comments on commit 88832b6

Please sign in to comment.