From b1ca71b3aa43f015e764e16e87a199ea0ccd2f03 Mon Sep 17 00:00:00 2001 From: Ioannis G Date: Sun, 11 Oct 2020 23:55:35 +0300 Subject: [PATCH] plugin/pkiller: improve kill-all option - better title, add count of matches in subtitle, use process icon - hide option when executable path is empty --- .../Languages/en.xaml | 3 ++- Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.ProcessKiller/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.ProcessKiller/Languages/en.xaml index 2eee31745..e7a136114 100644 --- a/Plugins/Flow.Launcher.Plugin.ProcessKiller/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.ProcessKiller/Languages/en.xaml @@ -5,7 +5,8 @@ Process Killer Kill running processes from Flow Launcher - kill all "{0}" processes + kill all instances of "{0}" + kill {0} processes kill all instances \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs b/Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs index faccc31dc..c3d9d1ab2 100644 --- a/Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs @@ -89,6 +89,7 @@ namespace Flow.Launcher.Plugin.ProcessKiller SubTitle = path, TitleHighlightData = StringMatcher.FuzzySearch(termToSearch, p.ProcessName).MatchData, Score = pr.Score, + ContextData = p.ProcessName, Action = (c) => { processHelper.TryKill(p); @@ -101,14 +102,14 @@ namespace Flow.Launcher.Plugin.ProcessKiller // When there are multiple results AND all of them are instances of the same executable // add a quick option to kill them all at the top of the results. - var firstResult = sortedResults.FirstOrDefault()?.SubTitle; - if (processlist.Count > 1 && !string.IsNullOrEmpty(termToSearch) && sortedResults.All(r => r.SubTitle == firstResult)) + var firstResult = sortedResults.FirstOrDefault(x => !string.IsNullOrEmpty(x.SubTitle)); + if (processlist.Count > 1 && !string.IsNullOrEmpty(termToSearch) && sortedResults.All(r => r.SubTitle == firstResult?.SubTitle)) { sortedResults.Insert(1, new Result() { - IcoPath = "Images/app.png", - Title = string.Format(_context.API.GetTranslation("flowlauncher_plugin_processkiller_kill_all"), termToSearch), - SubTitle = "", + IcoPath = firstResult?.IcoPath, + Title = string.Format(_context.API.GetTranslation("flowlauncher_plugin_processkiller_kill_all"), firstResult?.ContextData), + SubTitle = string.Format(_context.API.GetTranslation("flowlauncher_plugin_processkiller_kill_all_count"), processlist.Count), Score = 200, Action = (c) => {