From 9e11b0cd9dc9265efc7f0a86d46b9391f2e051b4 Mon Sep 17 00:00:00 2001 From: TheBestPessimist Date: Mon, 30 Jan 2023 14:44:48 +0200 Subject: [PATCH 1/5] whitespace --- .../Programs/Win32.cs | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index 0798857ed..0762be5b7 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -25,23 +25,29 @@ namespace Flow.Launcher.Plugin.Program.Programs public string Name { get; set; } public string UniqueIdentifier { get => _uid; set => _uid = value == null ? string.Empty : value.ToLowerInvariant(); } // For path comparison public string IcoPath { get; set; } + /// /// Path of the file. It's the path of .lnk and .url for .lnk and .url files. /// public string FullPath { get; set; } + /// /// Path of the executable for .lnk, or the URL for .url. Arguments are included if any. /// public string LnkResolvedPath { get; set; } + /// /// Path of the actual executable file. Args are included. /// public string ExecutablePath => LnkResolvedPath ?? FullPath; + public string ParentDirectory { get; set; } + /// /// Name of the executable for .lnk files /// public string ExecutableName { get; set; } + public string Description { get; set; } public bool Valid { get; set; } public bool Enabled { get; set; } @@ -199,9 +205,7 @@ namespace Flow.Launcher.Plugin.Program.Programs { var info = new ProcessStartInfo { - FileName = FullPath, - WorkingDirectory = ParentDirectory, - UseShellExecute = true + FileName = FullPath, WorkingDirectory = ParentDirectory, UseShellExecute = true }; Task.Run(() => Main.StartProcess(ShellCommand.RunAsDifferentUser, info)); @@ -363,6 +367,7 @@ namespace Flow.Launcher.Plugin.Program.Programs { return program; } + foreach (var protocol in protocols) { if (url.StartsWith(protocol)) @@ -418,10 +423,12 @@ namespace Flow.Launcher.Plugin.Program.Programs if (!Directory.Exists(directory)) return Enumerable.Empty(); - return Directory.EnumerateFiles(directory, "*", new EnumerationOptions - { - IgnoreInaccessible = true, RecurseSubdirectories = recursive - }).Where(x => suffixes.Contains(Extension(x))); + return Directory + .EnumerateFiles( + directory, + "*", + new EnumerationOptions { IgnoreInaccessible = true, RecurseSubdirectories = recursive }) + .Where(x => suffixes.Contains(Extension(x))); } private static string Extension(string path) @@ -471,7 +478,7 @@ namespace Flow.Launcher.Plugin.Program.Programs } var paths = pathEnv.Split(";", StringSplitOptions.RemoveEmptyEntries).DistinctBy(p => p.ToLowerInvariant()); - + var toFilter = paths.Where(x => commonParents.All(parent => !FilesFolders.PathContains(parent, x))) .AsParallel() .SelectMany(p => EnumerateProgramsInDir(p, suffixes, recursive: false)); From e89d8b3577e09d48d12960ada44ee941ccdad041 Mon Sep 17 00:00:00 2001 From: TheBestPessimist Date: Mon, 30 Jan 2023 14:47:27 +0200 Subject: [PATCH 2/5] Read list of programs from `Start Menu` instead of `Start Menu/Programs` --- .../Programs/Win32.cs | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index 0762be5b7..986a8da67 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -457,14 +457,11 @@ namespace Flow.Launcher.Plugin.Program.Programs private static IEnumerable StartMenuPrograms(string[] suffixes, string[] protocols) { - var directory1 = Environment.GetFolderPath(Environment.SpecialFolder.Programs); - var directory2 = Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms); - var paths1 = EnumerateProgramsInDir(directory1, suffixes); - var paths2 = EnumerateProgramsInDir(directory2, suffixes); + var allPrograms = GetStartMenuPaths() + .SelectMany(p => EnumerateProgramsInDir(p, suffixes)) + .Distinct(); - var toFilter = paths1.Concat(paths2); - - var programs = ExceptDisabledSource(toFilter.Distinct()) + var programs = ExceptDisabledSource(allPrograms) .Select(x => GetProgramFromPath(x, protocols)); return programs; } @@ -702,12 +699,10 @@ namespace Flow.Launcher.Plugin.Program.Programs private static IEnumerable GetStartMenuPaths() { - var directory1 = Environment.GetFolderPath(Environment.SpecialFolder.Programs); - var directory2 = Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms); - return new[] - { - directory1, directory2 - }; + var userStartMenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); + var commonStartMenu = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartMenu); + + return new[] { userStartMenu, commonStartMenu }; } public static void WatchProgramUpdate(Settings settings) From 43cf3ded876b978c46bf901537941e63bbda91fd Mon Sep 17 00:00:00 2001 From: TheBestPessimist Date: Mon, 30 Jan 2023 14:48:15 +0200 Subject: [PATCH 3/5] version --- Plugins/Flow.Launcher.Plugin.Program/plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/plugin.json b/Plugins/Flow.Launcher.Plugin.Program/plugin.json index 3d20c0a48..e0894a33f 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.Program/plugin.json @@ -4,7 +4,7 @@ "Name": "Program", "Description": "Search programs in Flow.Launcher", "Author": "qianlifeng", - "Version": "2.2.0", + "Version": "2.3.0", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.Program.dll", From 2e0923d25bdef9bc1d943ffceed53918dcdc5726 Mon Sep 17 00:00:00 2001 From: TheBestPessimist Date: Mon, 30 Jan 2023 14:51:41 +0200 Subject: [PATCH 4/5] more whitespace --- Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index 986a8da67..4afedb9e4 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -205,7 +205,9 @@ namespace Flow.Launcher.Plugin.Program.Programs { var info = new ProcessStartInfo { - FileName = FullPath, WorkingDirectory = ParentDirectory, UseShellExecute = true + FileName = FullPath, + WorkingDirectory = ParentDirectory, + UseShellExecute = true }; Task.Run(() => Main.StartProcess(ShellCommand.RunAsDifferentUser, info)); @@ -423,10 +425,8 @@ namespace Flow.Launcher.Plugin.Program.Programs if (!Directory.Exists(directory)) return Enumerable.Empty(); - return Directory - .EnumerateFiles( - directory, - "*", + return Directory.EnumerateFiles( + directory, "*", new EnumerationOptions { IgnoreInaccessible = true, RecurseSubdirectories = recursive }) .Where(x => suffixes.Contains(Extension(x))); } From 30b73e5488f056c5d15cda6607070827f5910bdf Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Tue, 7 Feb 2023 01:26:30 +0800 Subject: [PATCH 5/5] Revert "version" This reverts commit 43cf3ded876b978c46bf901537941e63bbda91fd. --- Plugins/Flow.Launcher.Plugin.Program/plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/plugin.json b/Plugins/Flow.Launcher.Plugin.Program/plugin.json index e0894a33f..3d20c0a48 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.Program/plugin.json @@ -4,7 +4,7 @@ "Name": "Program", "Description": "Search programs in Flow.Launcher", "Author": "qianlifeng", - "Version": "2.3.0", + "Version": "2.2.0", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.Program.dll",