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/93] 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 6a8b232e9..cb467f740 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -17,6 +17,7 @@ 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 { @@ -275,6 +276,14 @@ namespace Flow.Launcher.Plugin.Program.Programs 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 @@ namespace Flow.Launcher.Plugin.Program.Programs 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 @@ namespace Flow.Launcher.Plugin.Program.Programs 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 d97ddd993..09e135d9b 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs @@ -12,10 +12,11 @@ namespace Flow.Launcher.Plugin.Program 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 f07879465..1095eaf45 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 @@ namespace Flow.Launcher.Plugin.Program.Views } } } -} \ 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/93] 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 f0a53ed77..2178c8ef5 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Main.cs @@ -102,7 +102,7 @@ namespace Flow.Launcher.Plugin.Program 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/93] 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 cb467f740..cfd190c23 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -389,7 +389,7 @@ namespace Flow.Launcher.Plugin.Program.Programs } 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/93] 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 cfd190c23..b8bfbef8a 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -318,14 +318,14 @@ namespace Flow.Launcher.Plugin.Program.Programs } } - 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 @@ namespace Flow.Launcher.Plugin.Program.Programs 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/93] 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 8d8cae02c..b48c7e1de 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 1095eaf45..d59bd8690 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/93] 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 d59bd8690..2fbb5f82a 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/93] 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 b8bfbef8a..f0c783d76 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -565,7 +565,7 @@ namespace Flow.Launcher.Plugin.Program.Programs 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/93] 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 f0c783d76..656429f22 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -361,7 +361,6 @@ namespace Flow.Launcher.Plugin.Program.Programs private static IEnumerable 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 @@ namespace Flow.Launcher.Plugin.Program.Programs 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/93] 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 656429f22..8821ef817 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.Infrastructure; 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 f6233525395a3e5376836c981969cd44157bc205 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Oct 2022 22:37:23 +0000 Subject: [PATCH 10/93] Bump System.Data.SQLite.Core from 1.0.114.3 to 1.0.116 Bumps System.Data.SQLite.Core from 1.0.114.3 to 1.0.116. --- updated-dependencies: - dependency-name: System.Data.SQLite.Core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .../Flow.Launcher.Plugin.BrowserBookmark.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj index 8454b11e6..18b7da392 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj @@ -65,7 +65,7 @@ - + From c56c343ed6c7fbfae717dc6cce7a55e8f2a952a3 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Tue, 18 Oct 2022 14:51:13 +0800 Subject: [PATCH 11/93] Add Checkbox to edit program source window 1. Add Checkbox to edit program source window 2. Double click item to edit --- .../AddProgramSource.xaml | 93 ++++++++++++++----- .../AddProgramSource.xaml.cs | 38 ++++---- .../Views/ProgramSetting.xaml | 1 + .../Views/ProgramSetting.xaml.cs | 19 +++- 4 files changed, 107 insertions(+), 44 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml b/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml index 9230eb062..b1e21a3e3 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml @@ -5,12 +5,12 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Title="{DynamicResource flowlauncher_plugin_program_directory}" - Width="400" + Width="530" Background="{DynamicResource PopuBGColor}" Foreground="{DynamicResource PopupTextColor}" + ResizeMode="NoResize" SizeToContent="Height" - WindowStartupLocation="CenterScreen" - mc:Ignorable="d"> + WindowStartupLocation="CenterScreen"> @@ -19,7 +19,6 @@ - @@ -53,8 +52,8 @@ - - + + - - -