From ff92f6f5c799311d3bcf27df7f79e060cc8fa202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Br=C3=BCheim?= Date: Mon, 8 Mar 2021 23:18:50 +0100 Subject: [PATCH] Fixes #17 Sort process list foreground first, then alphabetically --- kill.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kill.py b/kill.py index ba14b7d..98d3ca7 100644 --- a/kill.py +++ b/kill.py @@ -500,7 +500,12 @@ def on_suggest(self, user_input, items_chain): if not self._processes: self._get_processes() - self.set_suggestions(self._processes, kp.Match.FUZZY, kp.Sort.SCORE_DESC) + if user_input: + self.set_suggestions(self._processes, kp.Match.FUZZY, kp.Sort.SCORE_DESC) + else: + self.set_suggestions(sorted(self._processes, key=lambda p: (p.label().endswith("(background)"), p.label().lower())), + kp.Match.ANY, + kp.Sort.NONE) def on_execute(self, item, action): """Executes the selected (or default) kill action on the selected item