From 63912aaa623637d1f55ff28a15c491ac99be1da5 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 15 Oct 2022 21:24:02 +0800 Subject: [PATCH 01/31] Add PATH environment variable to program source --- .../Programs/Win32.cs | 41 +++++++++++++++++++ .../Flow.Launcher.Plugin.Program/Settings.cs | 3 +- .../Views/ProgramSetting.xaml | 9 ++++ .../Views/ProgramSetting.xaml.cs | 14 ++++++- 4 files changed, 64 insertions(+), 3 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index 6a8b232e94e..cb467f7401b 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -17,6 +17,7 @@ using Stopwatch = Flow.Launcher.Infrastructure.Stopwatch; using System.Diagnostics.CodeAnalysis; using System.Threading.Channels; +using System.Collections.ObjectModel; namespace Flow.Launcher.Plugin.Program.Programs { @@ -275,6 +276,14 @@ private static Win32 LnkProgram(string path) program.Valid = false; return program; } + catch (FileNotFoundException e) + { + ProgramLogger.LogException($"|Win32|LnkProgram|{path}" + + "|An unexpected error occurred in the calling method LnkProgram", e); + + program.Valid = false; + return program; + } #if !DEBUG //Only do a catch all in production. This is so make developer aware of any unhandled exception and add the exception handling in. catch (Exception e) { @@ -370,6 +379,32 @@ private static IEnumerable StartMenuPrograms(string[] suffixes) return programs; } + private static IEnumerable PATHPrograms(string[] suffixes) + { + var disabledProgramsList = Main._settings.DisabledProgramSources; + + string? pathEnv = Environment.GetEnvironmentVariable("Path"); + if (String.IsNullOrEmpty(pathEnv)) { + return Array.Empty(); + } + + var toFilter = new List(); + var paths = pathEnv.Split(";", StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(x => x.ToLower()).Distinct(); + + foreach (var path in paths) + { + var p = ProgramPaths(path, suffixes); + toFilter.AddRange(p); + } + var programs = ExceptDisabledSource(toFilter.Distinct()) + .Select(x => Extension(x) switch + { + ShortcutExtension => LnkProgram(x), + _ => Win32Program(x) + }).Where(x => x.Valid); + return programs; + } + private static IEnumerable AppPathsPrograms(string[] suffixes) { // https://msdn.microsoft.com/en-us/library/windows/desktop/ee872121 @@ -522,6 +557,12 @@ public static Win32[] All(Settings settings) autoIndexPrograms = autoIndexPrograms.Concat(startMenu); } + if (settings.EnablePATHSource) + { + var path = PATHPrograms(settings.ProgramSuffixes); + autoIndexPrograms = autoIndexPrograms.Concat(path); + } + autoIndexPrograms = ProgramsHasher(autoIndexPrograms); return programs.Concat(autoIndexPrograms).Distinct().ToArray(); diff --git a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs index d97ddd9932a..09e135d9b73 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs @@ -12,10 +12,11 @@ public class Settings public string[] ProgramSuffixes { get; set; } = {"appref-ms", "exe", "lnk"}; public bool EnableStartMenuSource { get; set; } = true; - public bool EnableDescription { get; set; } = false; public bool HideAppsPath { get; set; } = true; public bool EnableRegistrySource { get; set; } = true; + public bool EnablePATHSource { get; set; } = false; + public string CustomizedExplorer { get; set; } = Explorer; public string CustomizedArgs { get; set; } = ExplorerArgs; diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml index f078794654b..1095eaf4517 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml @@ -54,10 +54,19 @@ IsChecked="{Binding EnableDescription}" ToolTip="{DynamicResource flowlauncher_plugin_program_enable_description_tooltip}" /> + + + + _settings.EnablePATHSource; + set + { + _settings.EnablePATHSource = value; + ReIndexing(); + } + } + public string CustomizedExplorerPath { get => _settings.CustomizedExplorer; @@ -360,4 +370,4 @@ private void Row_OnClick(object sender, RoutedEventArgs e) } } } -} \ No newline at end of file +} From ce1023876a1057dcb6d6089b0a0ca0cf33bff7c6 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 16 Oct 2022 00:32:24 +0800 Subject: [PATCH 02/31] Fix typo --- Plugins/Flow.Launcher.Plugin.Program/Main.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Main.cs b/Plugins/Flow.Launcher.Plugin.Program/Main.cs index f0a53ed7758..2178c8ef5cd 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Main.cs @@ -102,7 +102,7 @@ public async Task InitAsync(PluginInitContext context) var b = Task.Run(() => { - Stopwatch.Normal("|Flow.Launcher.Plugin.Program.Main|Win32Program index cost", IndexUwpPrograms); + Stopwatch.Normal("|Flow.Launcher.Plugin.Program.Main|UWPPRogram index cost", IndexUwpPrograms); }); if (cacheEmpty) From efd1b6cfdd4369d1b08c753725126acec810ff33 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 16 Oct 2022 01:24:07 +0800 Subject: [PATCH 03/31] minor fix --- Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index cb467f7401b..cfd190c2377 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -389,7 +389,7 @@ private static IEnumerable PATHPrograms(string[] suffixes) } var toFilter = new List(); - var paths = pathEnv.Split(";", StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(x => x.ToLower()).Distinct(); + var paths = pathEnv.Split(";", StringSplitOptions.RemoveEmptyEntries).DistinctBy(p => p.ToLower()); foreach (var path in paths) { From 0635ebd28bac1180cc50df5c2d9e4e0ef1577e89 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 16 Oct 2022 02:28:29 +0800 Subject: [PATCH 04/31] Disable recursive search for PATH folders --- Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index cfd190c2377..b8bfbef8a94 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -318,14 +318,14 @@ private static Win32 ExeProgram(string path) } } - private static IEnumerable ProgramPaths(string directory, string[] suffixes) + private static IEnumerable ProgramPaths(string directory, string[] suffixes, bool recursive=true) { if (!Directory.Exists(directory)) return Enumerable.Empty(); return Directory.EnumerateFiles(directory, "*", new EnumerationOptions { - IgnoreInaccessible = true, RecurseSubdirectories = true + IgnoreInaccessible = true, RecurseSubdirectories = recursive }).Where(x => suffixes.Contains(Extension(x))); } @@ -393,7 +393,7 @@ private static IEnumerable PATHPrograms(string[] suffixes) foreach (var path in paths) { - var p = ProgramPaths(path, suffixes); + var p = ProgramPaths(path, suffixes, recursive:false); toFilter.AddRange(p); } var programs = ExceptDisabledSource(toFilter.Distinct()) From 4dc05ba46e495714333c4c58c0b176db29a5f5e9 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 16 Oct 2022 02:40:03 +0800 Subject: [PATCH 05/31] Text key update --- Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml | 2 ++ .../Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml index 8d8cae02c9f..b48c7e1de69 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml @@ -19,6 +19,8 @@ When enabled, Flow will load programs from the start menu Index Registry When enabled, Flow will load programs from the registry + Index PATH + When enabled, Flow will load programs from the PATH environment variable Hide app path For executable files such as UWP or lnk, hide the file path from being visible Search in Program Description diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml index 1095eaf4517..d59bd86904a 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml @@ -63,9 +63,9 @@ + ToolTip="{DynamicResource flowlauncher_plugin_program_index_PATH_tooltip}" /> Date: Sun, 16 Oct 2022 13:34:06 +0800 Subject: [PATCH 06/31] Change UI --- .../Views/ProgramSetting.xaml | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml index d59bd86904a..2fbb5f82a5e 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml @@ -22,7 +22,6 @@ + - - - - - Date: Sun, 16 Oct 2022 20:18:26 +0800 Subject: [PATCH 07/31] Remove duplicate win32 programs --- Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index b8bfbef8a94..f0c783d766d 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -565,7 +565,7 @@ public static Win32[] All(Settings settings) autoIndexPrograms = ProgramsHasher(autoIndexPrograms); - return programs.Concat(autoIndexPrograms).Distinct().ToArray(); + return ProgramsHasher(programs.Concat(autoIndexPrograms)).ToArray(); } #if DEBUG //This is to make developer aware of any unhandled exception and add in handling. catch (Exception) From 9de0b392ea40772cfc1e5ca3fd7cb926a6a53de8 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 16 Oct 2022 21:15:40 +0800 Subject: [PATCH 08/31] Use Linq --- .../Flow.Launcher.Plugin.Program/Programs/Win32.cs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index f0c783d766d..656429f2236 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -361,7 +361,6 @@ private static IEnumerable UnregisteredPrograms(List StartMenuPrograms(string[] suffixes) { - var disabledProgramsList = Main._settings.DisabledProgramSources; var directory1 = Environment.GetFolderPath(Environment.SpecialFolder.Programs); var directory2 = Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms); @@ -381,21 +380,15 @@ private static IEnumerable StartMenuPrograms(string[] suffixes) private static IEnumerable PATHPrograms(string[] suffixes) { - var disabledProgramsList = Main._settings.DisabledProgramSources; - - string? pathEnv = Environment.GetEnvironmentVariable("Path"); + var pathEnv = Environment.GetEnvironmentVariable("Path"); if (String.IsNullOrEmpty(pathEnv)) { return Array.Empty(); } - var toFilter = new List(); var paths = pathEnv.Split(";", StringSplitOptions.RemoveEmptyEntries).DistinctBy(p => p.ToLower()); - foreach (var path in paths) - { - var p = ProgramPaths(path, suffixes, recursive:false); - toFilter.AddRange(p); - } + var toFilter = paths.SelectMany(p => ProgramPaths(p, suffixes, recursive:false)); + var programs = ExceptDisabledSource(toFilter.Distinct()) .Select(x => Extension(x) switch { From a3adc4dcc0666251ec2ea9a976281ecff851731c Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 16 Oct 2022 23:02:35 +0800 Subject: [PATCH 09/31] Remove unused using --- Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index 656429f2236..8821ef81795 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -11,13 +11,9 @@ using Flow.Launcher.Plugin.Program.Logger; using Flow.Launcher.Plugin.SharedCommands; using Flow.Launcher.Plugin.SharedModels; -using Flow.Launcher.Infrastructure.Logger; -using System.Collections; using System.Diagnostics; -using Stopwatch = Flow.Launcher.Infrastructure.Stopwatch; using System.Diagnostics.CodeAnalysis; using System.Threading.Channels; -using System.Collections.ObjectModel; namespace Flow.Launcher.Plugin.Program.Programs { From 13a8f82bfe5b8ef9d7bdac59606b1b886e8c90e7 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 15 Oct 2022 21:24:02 +0800 Subject: [PATCH 10/31] Add PATH environment variable to program source --- .../Programs/Win32.cs | 41 +++++++++++++++++++ .../Flow.Launcher.Plugin.Program/Settings.cs | 3 +- .../Views/ProgramSetting.xaml | 9 ++++ .../Views/ProgramSetting.xaml.cs | 14 ++++++- 4 files changed, 64 insertions(+), 3 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index 6a8b232e94e..cb467f7401b 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -17,6 +17,7 @@ using Stopwatch = Flow.Launcher.Infrastructure.Stopwatch; using System.Diagnostics.CodeAnalysis; using System.Threading.Channels; +using System.Collections.ObjectModel; namespace Flow.Launcher.Plugin.Program.Programs { @@ -275,6 +276,14 @@ private static Win32 LnkProgram(string path) program.Valid = false; return program; } + catch (FileNotFoundException e) + { + ProgramLogger.LogException($"|Win32|LnkProgram|{path}" + + "|An unexpected error occurred in the calling method LnkProgram", e); + + program.Valid = false; + return program; + } #if !DEBUG //Only do a catch all in production. This is so make developer aware of any unhandled exception and add the exception handling in. catch (Exception e) { @@ -370,6 +379,32 @@ private static IEnumerable StartMenuPrograms(string[] suffixes) return programs; } + private static IEnumerable PATHPrograms(string[] suffixes) + { + var disabledProgramsList = Main._settings.DisabledProgramSources; + + string? pathEnv = Environment.GetEnvironmentVariable("Path"); + if (String.IsNullOrEmpty(pathEnv)) { + return Array.Empty(); + } + + var toFilter = new List(); + var paths = pathEnv.Split(";", StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(x => x.ToLower()).Distinct(); + + foreach (var path in paths) + { + var p = ProgramPaths(path, suffixes); + toFilter.AddRange(p); + } + var programs = ExceptDisabledSource(toFilter.Distinct()) + .Select(x => Extension(x) switch + { + ShortcutExtension => LnkProgram(x), + _ => Win32Program(x) + }).Where(x => x.Valid); + return programs; + } + private static IEnumerable AppPathsPrograms(string[] suffixes) { // https://msdn.microsoft.com/en-us/library/windows/desktop/ee872121 @@ -522,6 +557,12 @@ public static Win32[] All(Settings settings) autoIndexPrograms = autoIndexPrograms.Concat(startMenu); } + if (settings.EnablePATHSource) + { + var path = PATHPrograms(settings.ProgramSuffixes); + autoIndexPrograms = autoIndexPrograms.Concat(path); + } + autoIndexPrograms = ProgramsHasher(autoIndexPrograms); return programs.Concat(autoIndexPrograms).Distinct().ToArray(); diff --git a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs index d97ddd9932a..09e135d9b73 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs @@ -12,10 +12,11 @@ public class Settings public string[] ProgramSuffixes { get; set; } = {"appref-ms", "exe", "lnk"}; public bool EnableStartMenuSource { get; set; } = true; - public bool EnableDescription { get; set; } = false; public bool HideAppsPath { get; set; } = true; public bool EnableRegistrySource { get; set; } = true; + public bool EnablePATHSource { get; set; } = false; + public string CustomizedExplorer { get; set; } = Explorer; public string CustomizedArgs { get; set; } = ExplorerArgs; diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml index f078794654b..1095eaf4517 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml @@ -54,10 +54,19 @@ IsChecked="{Binding EnableDescription}" ToolTip="{DynamicResource flowlauncher_plugin_program_enable_description_tooltip}" /> + + + + _settings.EnablePATHSource; + set + { + _settings.EnablePATHSource = value; + ReIndexing(); + } + } + public string CustomizedExplorerPath { get => _settings.CustomizedExplorer; @@ -360,4 +370,4 @@ private void Row_OnClick(object sender, RoutedEventArgs e) } } } -} \ No newline at end of file +} From e6c933851a68bf84cfde4791bdd8d547efec2aa9 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 16 Oct 2022 00:32:24 +0800 Subject: [PATCH 11/31] Fix typo --- Plugins/Flow.Launcher.Plugin.Program/Main.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Main.cs b/Plugins/Flow.Launcher.Plugin.Program/Main.cs index f0a53ed7758..2178c8ef5cd 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Main.cs @@ -102,7 +102,7 @@ public async Task InitAsync(PluginInitContext context) var b = Task.Run(() => { - Stopwatch.Normal("|Flow.Launcher.Plugin.Program.Main|Win32Program index cost", IndexUwpPrograms); + Stopwatch.Normal("|Flow.Launcher.Plugin.Program.Main|UWPPRogram index cost", IndexUwpPrograms); }); if (cacheEmpty) From d90d1156548441e79a6f0d077121529e56a7e01b Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 16 Oct 2022 01:24:07 +0800 Subject: [PATCH 12/31] minor fix --- Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index cb467f7401b..cfd190c2377 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -389,7 +389,7 @@ private static IEnumerable PATHPrograms(string[] suffixes) } var toFilter = new List(); - var paths = pathEnv.Split(";", StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(x => x.ToLower()).Distinct(); + var paths = pathEnv.Split(";", StringSplitOptions.RemoveEmptyEntries).DistinctBy(p => p.ToLower()); foreach (var path in paths) { From a171addf4cee3f70fd78743549295cd345611c87 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 16 Oct 2022 02:28:29 +0800 Subject: [PATCH 13/31] Disable recursive search for PATH folders --- Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index cfd190c2377..b8bfbef8a94 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -318,14 +318,14 @@ private static Win32 ExeProgram(string path) } } - private static IEnumerable ProgramPaths(string directory, string[] suffixes) + private static IEnumerable ProgramPaths(string directory, string[] suffixes, bool recursive=true) { if (!Directory.Exists(directory)) return Enumerable.Empty(); return Directory.EnumerateFiles(directory, "*", new EnumerationOptions { - IgnoreInaccessible = true, RecurseSubdirectories = true + IgnoreInaccessible = true, RecurseSubdirectories = recursive }).Where(x => suffixes.Contains(Extension(x))); } @@ -393,7 +393,7 @@ private static IEnumerable PATHPrograms(string[] suffixes) foreach (var path in paths) { - var p = ProgramPaths(path, suffixes); + var p = ProgramPaths(path, suffixes, recursive:false); toFilter.AddRange(p); } var programs = ExceptDisabledSource(toFilter.Distinct()) From afa01559b0732b6a786a76a447d76062ff073e78 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 16 Oct 2022 02:40:03 +0800 Subject: [PATCH 14/31] Text key update --- Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml | 2 ++ .../Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml index 8d8cae02c9f..b48c7e1de69 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml @@ -19,6 +19,8 @@ When enabled, Flow will load programs from the start menu Index Registry When enabled, Flow will load programs from the registry + Index PATH + When enabled, Flow will load programs from the PATH environment variable Hide app path For executable files such as UWP or lnk, hide the file path from being visible Search in Program Description diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml index 1095eaf4517..d59bd86904a 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml @@ -63,9 +63,9 @@ + ToolTip="{DynamicResource flowlauncher_plugin_program_index_PATH_tooltip}" /> Date: Sun, 16 Oct 2022 13:34:06 +0800 Subject: [PATCH 15/31] Change UI --- .../Views/ProgramSetting.xaml | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml index d59bd86904a..2fbb5f82a5e 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml @@ -22,7 +22,6 @@ + - - - - - Date: Sun, 16 Oct 2022 20:18:26 +0800 Subject: [PATCH 16/31] Remove duplicate win32 programs --- Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index b8bfbef8a94..f0c783d766d 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -565,7 +565,7 @@ public static Win32[] All(Settings settings) autoIndexPrograms = ProgramsHasher(autoIndexPrograms); - return programs.Concat(autoIndexPrograms).Distinct().ToArray(); + return ProgramsHasher(programs.Concat(autoIndexPrograms)).ToArray(); } #if DEBUG //This is to make developer aware of any unhandled exception and add in handling. catch (Exception) From 679157949453c9299cc290b5b908fa6e2e759169 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 16 Oct 2022 21:15:40 +0800 Subject: [PATCH 17/31] Use Linq --- .../Flow.Launcher.Plugin.Program/Programs/Win32.cs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index f0c783d766d..656429f2236 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -361,7 +361,6 @@ private static IEnumerable UnregisteredPrograms(List StartMenuPrograms(string[] suffixes) { - var disabledProgramsList = Main._settings.DisabledProgramSources; var directory1 = Environment.GetFolderPath(Environment.SpecialFolder.Programs); var directory2 = Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms); @@ -381,21 +380,15 @@ private static IEnumerable StartMenuPrograms(string[] suffixes) private static IEnumerable PATHPrograms(string[] suffixes) { - var disabledProgramsList = Main._settings.DisabledProgramSources; - - string? pathEnv = Environment.GetEnvironmentVariable("Path"); + var pathEnv = Environment.GetEnvironmentVariable("Path"); if (String.IsNullOrEmpty(pathEnv)) { return Array.Empty(); } - var toFilter = new List(); var paths = pathEnv.Split(";", StringSplitOptions.RemoveEmptyEntries).DistinctBy(p => p.ToLower()); - foreach (var path in paths) - { - var p = ProgramPaths(path, suffixes, recursive:false); - toFilter.AddRange(p); - } + var toFilter = paths.SelectMany(p => ProgramPaths(p, suffixes, recursive:false)); + var programs = ExceptDisabledSource(toFilter.Distinct()) .Select(x => Extension(x) switch { From 2672460cc888a32907eeccdcc7e079dff6b88a67 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 16 Oct 2022 23:02:35 +0800 Subject: [PATCH 18/31] Remove unused using --- Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index 656429f2236..8821ef81795 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -11,13 +11,9 @@ using Flow.Launcher.Plugin.Program.Logger; using Flow.Launcher.Plugin.SharedCommands; using Flow.Launcher.Plugin.SharedModels; -using Flow.Launcher.Infrastructure.Logger; -using System.Collections; using System.Diagnostics; -using Stopwatch = Flow.Launcher.Infrastructure.Stopwatch; using System.Diagnostics.CodeAnalysis; using System.Threading.Channels; -using System.Collections.ObjectModel; namespace Flow.Launcher.Plugin.Program.Programs { From ac7a1a7ce817366341cc425f23ed6bdc26cca6d2 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Mon, 31 Oct 2022 22:02:10 +0800 Subject: [PATCH 19/31] Revert "Remove duplicate win32 programs" This reverts commit d5d141f9db6d8c2e96cfbb96246db3405de58df6. --- Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index 8821ef81795..32fcc908203 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -554,7 +554,7 @@ public static Win32[] All(Settings settings) autoIndexPrograms = ProgramsHasher(autoIndexPrograms); - return ProgramsHasher(programs.Concat(autoIndexPrograms)).ToArray(); + return programs.Concat(autoIndexPrograms).Distinct().ToArray(); } #if DEBUG //This is to make developer aware of any unhandled exception and add in handling. catch (Exception) From 24afcb22a15f4d466da4329fdc1b08ac0c189e97 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Tue, 1 Nov 2022 01:18:54 +0800 Subject: [PATCH 20/31] minor fix --- Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index 32fcc908203..f68fa34fef1 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -381,7 +381,7 @@ private static IEnumerable PATHPrograms(string[] suffixes) return Array.Empty(); } - var paths = pathEnv.Split(";", StringSplitOptions.RemoveEmptyEntries).DistinctBy(p => p.ToLower()); + var paths = pathEnv.Split(";", StringSplitOptions.RemoveEmptyEntries).DistinctBy(p => p.ToLowerInvariant()); var toFilter = paths.SelectMany(p => ProgramPaths(p, suffixes, recursive:false)); From 2d0f42590a97292033683fef9ad262b1d047619a Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Tue, 1 Nov 2022 01:36:19 +0800 Subject: [PATCH 21/31] fix separator --- .../Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml index 2fbb5f82a5e..71f64e3195d 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml @@ -58,6 +58,10 @@ IsChecked="{Binding EnableDescription}" ToolTip="{DynamicResource flowlauncher_plugin_program_enable_description_tooltip}" /> + Date: Tue, 1 Nov 2022 01:37:31 +0800 Subject: [PATCH 22/31] enable path by default --- Plugins/Flow.Launcher.Plugin.Program/Settings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs index 09e135d9b73..93969afd8ab 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs @@ -15,7 +15,7 @@ public class Settings public bool EnableDescription { get; set; } = false; public bool HideAppsPath { get; set; } = true; public bool EnableRegistrySource { get; set; } = true; - public bool EnablePATHSource { get; set; } = false; + public bool EnablePATHSource { get; set; } = true; public string CustomizedExplorer { get; set; } = Explorer; public string CustomizedArgs { get; set; } = ExplorerArgs; From f4b933ad5e90da5395b110075f3f2c504dcd7b8e Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Tue, 1 Nov 2022 18:30:26 +0800 Subject: [PATCH 23/31] Fix UI layout --- .../Views/ProgramSetting.xaml | 109 +++++------------- 1 file changed, 28 insertions(+), 81 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml index 71f64e3195d..96449c7bb13 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml @@ -10,7 +10,7 @@ mc:Ignorable="d"> - + @@ -19,9 +19,30 @@ HorizontalAlignment="Stretch" Orientation="Vertical"> + + + + + + - - + - + Content="{DynamicResource flowlauncher_plugin_program_index_PATH}" + IsChecked="{Binding EnablePATHSource}" + ToolTip="{DynamicResource flowlauncher_plugin_program_index_PATH_tooltip}" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 7f322fe73c7c5b3962c0b4c767e0bf8339637cad Mon Sep 17 00:00:00 2001 From: DB p Date: Wed, 2 Nov 2022 12:20:26 +0900 Subject: [PATCH 24/31] Adjust Checkboxes layout --- .../Views/ProgramSetting.xaml | 92 ++++++++----------- 1 file changed, 38 insertions(+), 54 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml index 96449c7bb13..6054b5c5404 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml @@ -10,7 +10,7 @@ mc:Ignorable="d"> - + @@ -18,61 +18,45 @@ Grid.Row="0" HorizontalAlignment="Stretch" Orientation="Vertical"> - - - - - - + + + - - - - - + + - - - - - + + + + Date: Wed, 2 Nov 2022 14:07:56 +0800 Subject: [PATCH 25/31] Index .url files in PATH --- Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index 74c4b24c41d..82d56afe4b4 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -434,6 +434,7 @@ private static IEnumerable PATHPrograms(string[] suffixes) .Select(x => Extension(x) switch { ShortcutExtension => LnkProgram(x), + UrlExtension => UrlProgram(x), _ => Win32Program(x) }).Where(x => x.Valid); return programs; From f8346e4c18e06076b6f2c403d1d9f7ab806a65ad Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Wed, 2 Nov 2022 14:12:42 +0800 Subject: [PATCH 26/31] Merge update --- Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs | 2 +- Plugins/Flow.Launcher.Plugin.Program/Settings.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index 82d56afe4b4..c2bbf6df8ee 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -594,7 +594,7 @@ public static Win32[] All(Settings settings) if (settings.EnablePATHSource) { - var path = PATHPrograms(settings.ProgramSuffixes); + var path = PATHPrograms(settings.GetSuffixes()); autoIndexPrograms = autoIndexPrograms.Concat(path); } diff --git a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs index 2553d1e2640..4929d4b09e3 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using System.Text.Json.Serialization; +using PropertyChanged; using Windows.Foundation.Metadata; namespace Flow.Launcher.Plugin.Program @@ -13,7 +14,7 @@ public class Settings public List ProgramSources { get; set; } = new List(); public List DisabledProgramSources { get; set; } = new List(); - [Obsolete, JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + [Obsolete("Should use GetSuffixes() instead."), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public string[] ProgramSuffixes { get; set; } = null; public string[] CustomSuffixes { get; set; } = Array.Empty(); // Custom suffixes only public string[] CustomProtocols { get; set; } = Array.Empty(); From 187b195ff411dddc84280fcb02a45e0bf7fef973 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Thu, 3 Nov 2022 18:03:29 +0800 Subject: [PATCH 27/31] use ExeProgram for .exe --- Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index c2bbf6df8ee..2942c44d1e5 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -435,6 +435,7 @@ private static IEnumerable PATHPrograms(string[] suffixes) { ShortcutExtension => LnkProgram(x), UrlExtension => UrlProgram(x), + ExeExtension => ExeProgram(x), _ => Win32Program(x) }).Where(x => x.Valid); return programs; From 55bc7cde97bef3b291b3f8b03c2df81b04605d16 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Thu, 3 Nov 2022 18:07:28 +0800 Subject: [PATCH 28/31] formatting --- Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index 2942c44d1e5..45bfa368214 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -357,7 +357,7 @@ private static Win32 ExeProgram(string path) } } - private static IEnumerable ProgramPaths(string directory, string[] suffixes, bool recursive=true) + private static IEnumerable ProgramPaths(string directory, string[] suffixes, bool recursive = true) { if (!Directory.Exists(directory)) return Enumerable.Empty(); @@ -422,13 +422,14 @@ private static IEnumerable StartMenuPrograms(string[] suffixes) private static IEnumerable PATHPrograms(string[] suffixes) { var pathEnv = Environment.GetEnvironmentVariable("Path"); - if (String.IsNullOrEmpty(pathEnv)) { + if (String.IsNullOrEmpty(pathEnv)) + { return Array.Empty(); } var paths = pathEnv.Split(";", StringSplitOptions.RemoveEmptyEntries).DistinctBy(p => p.ToLowerInvariant()); - var toFilter = paths.SelectMany(p => ProgramPaths(p, suffixes, recursive:false)); + var toFilter = paths.SelectMany(p => ProgramPaths(p, suffixes, recursive: false)); var programs = ExceptDisabledSource(toFilter.Distinct()) .Select(x => Extension(x) switch From d2cb9c073ab41164c5c99836524785aca9eda4cd Mon Sep 17 00:00:00 2001 From: DB p Date: Sat, 5 Nov 2022 13:59:01 +0900 Subject: [PATCH 29/31] Adjust Setting Panel Layout --- .../Languages/en.xaml | 8 +- .../Views/ProgramSetting.xaml | 82 +++++++++++++------ 2 files changed, 62 insertions(+), 28 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml index 3893c92e170..7cf3af292d1 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml @@ -16,11 +16,13 @@ File Type Reindex Indexing - Index Start Menu + Index Source + Option + Start Menu When enabled, Flow will load programs from the start menu - Index Registry + Registry When enabled, Flow will load programs from the registry - Index PATH + PATH When enabled, Flow will load programs from the PATH environment variable Hide app path For executable files such as UWP or lnk, hide the file path from being visible diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml index 6054b5c5404..4d6db38fdb1 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml @@ -10,56 +10,88 @@ mc:Ignorable="d"> + - - - - - + LastChildFill="True"> + + - + + + + + + + + + + +