Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
63912aa
Add PATH environment variable to program source
VictoriousRaptor Oct 15, 2022
ce10238
Fix typo
VictoriousRaptor Oct 15, 2022
efd1b6c
minor fix
VictoriousRaptor Oct 15, 2022
0635ebd
Disable recursive search for PATH folders
VictoriousRaptor Oct 15, 2022
4dc05ba
Text key update
VictoriousRaptor Oct 15, 2022
600f929
Change UI
VictoriousRaptor Oct 16, 2022
cb6bfaf
Remove duplicate win32 programs
VictoriousRaptor Oct 16, 2022
9de0b39
Use Linq
VictoriousRaptor Oct 16, 2022
a3adc4d
Remove unused using
VictoriousRaptor Oct 16, 2022
167fed3
Merge branch 'dev' into SearchProgramsInPATH
VictoriousRaptor Oct 17, 2022
13a8f82
Add PATH environment variable to program source
VictoriousRaptor Oct 15, 2022
e6c9338
Fix typo
VictoriousRaptor Oct 15, 2022
d90d115
minor fix
VictoriousRaptor Oct 15, 2022
a171add
Disable recursive search for PATH folders
VictoriousRaptor Oct 15, 2022
afa0155
Text key update
VictoriousRaptor Oct 15, 2022
4334d28
Change UI
VictoriousRaptor Oct 16, 2022
d5d141f
Remove duplicate win32 programs
VictoriousRaptor Oct 16, 2022
6791579
Use Linq
VictoriousRaptor Oct 16, 2022
2672460
Remove unused using
VictoriousRaptor Oct 16, 2022
65db18c
Merge branch 'SearchProgramsInPATH' of https://github.com/VictoriousR…
VictoriousRaptor Oct 19, 2022
ac7a1a7
Revert "Remove duplicate win32 programs"
VictoriousRaptor Oct 31, 2022
24afcb2
minor fix
VictoriousRaptor Oct 31, 2022
2d0f425
fix separator
VictoriousRaptor Oct 31, 2022
88d6b0a
enable path by default
VictoriousRaptor Oct 31, 2022
f4b933a
Fix UI layout
VictoriousRaptor Nov 1, 2022
7f322fe
Adjust Checkboxes layout
onesounds Nov 2, 2022
7031971
Merge branch 'dev' into SearchProgramsInPATH
onesounds Nov 2, 2022
d181891
Merge branch 'dev' into SearchProgramsInPATH
VictoriousRaptor Nov 2, 2022
da755fa
Index .url files in PATH
VictoriousRaptor Nov 2, 2022
f8346e4
Merge update
VictoriousRaptor Nov 2, 2022
187b195
use ExeProgram for .exe
VictoriousRaptor Nov 3, 2022
55bc7cd
formatting
VictoriousRaptor Nov 3, 2022
d2cb9c0
Adjust Setting Panel Layout
onesounds Nov 5, 2022
b54dab5
adjust texts
VictoriousRaptor Nov 5, 2022
4062ce6
Merge branch 'dev' into SearchProgramsInPATH
VictoriousRaptor Nov 5, 2022
40d06e9
Merge branch 'Flow-Launcher:dev' into SearchProgramsInPATH
VictoriousRaptor Nov 8, 2022
a67e719
merge fix
VictoriousRaptor Nov 8, 2022
2263c94
Merge branch 'dev' into SearchProgramsInPATH
VictoriousRaptor Nov 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@
<system:String x:Key="flowlauncher_plugin_program_suffixes">File Type</system:String>
<system:String x:Key="flowlauncher_plugin_program_reindex">Reindex</system:String>
<system:String x:Key="flowlauncher_plugin_program_indexing">Indexing</system:String>
<system:String x:Key="flowlauncher_plugin_program_index_start">Index Start Menu</system:String>
<system:String x:Key="flowlauncher_plugin_program_index_source">Index Sources</system:String>
<system:String x:Key="flowlauncher_plugin_program_index_option">Options</system:String>
<system:String x:Key="flowlauncher_plugin_program_index_start">Start Menu</system:String>
<system:String x:Key="flowlauncher_plugin_program_index_start_tooltip">When enabled, Flow will load programs from the start menu</system:String>
<system:String x:Key="flowlauncher_plugin_program_index_registry">Index Registry</system:String>
<system:String x:Key="flowlauncher_plugin_program_index_registry">Registry</system:String>
<system:String x:Key="flowlauncher_plugin_program_index_registry_tooltip">When enabled, Flow will load programs from the registry</system:String>
<system:String x:Key="flowlauncher_plugin_program_index_PATH">PATH</system:String>
<system:String x:Key="flowlauncher_plugin_program_index_PATH_tooltip">When enabled, Flow will load programs from the PATH environment variable</system:String>
<system:String x:Key="flowlauncher_plugin_program_enable_hidelnkpath">Hide app path</system:String>
<system:String x:Key="flowlauncher_plugin_program_enable_hidelnkpath_tooltip">For executable files such as UWP or lnk, hide the file path from being visible</system:String>
<system:String x:Key="flowlauncher_plugin_program_enable_description">Search in Program Description</system:String>
Expand Down
2 changes: 1 addition & 1 deletion Plugins/Flow.Launcher.Plugin.Program/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
45 changes: 39 additions & 6 deletions Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
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.Text.RegularExpressions;
using System.Threading.Channels;
Expand Down Expand Up @@ -279,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)
{
Expand Down Expand Up @@ -352,14 +357,14 @@ private static Win32 ExeProgram(string path)
}
}

private static IEnumerable<string> ProgramPaths(string directory, string[] suffixes)
private static IEnumerable<string> ProgramPaths(string directory, string[] suffixes, bool recursive = true)
{
if (!Directory.Exists(directory))
return Enumerable.Empty<string>();

return Directory.EnumerateFiles(directory, "*", new EnumerationOptions
{
IgnoreInaccessible = true, RecurseSubdirectories = true
IgnoreInaccessible = true, RecurseSubdirectories = recursive
}).Where(x => suffixes.Contains(Extension(x)));
}

Expand Down Expand Up @@ -395,7 +400,6 @@ private static IEnumerable<Win32> UnregisteredPrograms(List<Settings.ProgramSour

private static IEnumerable<Win32> StartMenuPrograms(string[] suffixes)
{
var disabledProgramsList = Main._settings.DisabledProgramSources;

var directory1 = Environment.GetFolderPath(Environment.SpecialFolder.Programs);
var directory2 = Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms);
Expand All @@ -414,6 +418,29 @@ private static IEnumerable<Win32> StartMenuPrograms(string[] suffixes)
return programs;
}

private static IEnumerable<Win32> PATHPrograms(string[] suffixes)
{
var pathEnv = Environment.GetEnvironmentVariable("Path");
if (String.IsNullOrEmpty(pathEnv))
{
return Array.Empty<Win32>();
}

var paths = pathEnv.Split(";", StringSplitOptions.RemoveEmptyEntries).DistinctBy(p => p.ToLowerInvariant());

var toFilter = paths.AsParallel().SelectMany(p => ProgramPaths(p, suffixes, recursive: false));

var programs = ExceptDisabledSource(toFilter.Distinct())
.Select(x => Extension(x) switch
{
ShortcutExtension => LnkProgram(x),
UrlExtension => UrlProgram(x),
ExeExtension => ExeProgram(x),
_ => Win32Program(x)
});
return programs;
}

private static IEnumerable<Win32> AppPathsPrograms(string[] suffixes)
{
// https://msdn.microsoft.com/en-us/library/windows/desktop/ee872121
Expand Down Expand Up @@ -566,6 +593,12 @@ public static Win32[] All(Settings settings)
autoIndexPrograms = autoIndexPrograms.Concat(startMenu);
}

if (settings.EnablePATHSource)
{
var path = PATHPrograms(settings.GetSuffixes());
autoIndexPrograms = autoIndexPrograms.Concat(path);
}

autoIndexPrograms = ProgramsHasher(autoIndexPrograms);

return programs.Concat(autoIndexPrograms).Where(x => x.Valid).Distinct().ToArray();
Expand Down
5 changes: 4 additions & 1 deletion Plugins/Flow.Launcher.Plugin.Program/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -13,7 +14,7 @@ public class Settings
public List<ProgramSource> ProgramSources { get; set; } = new List<ProgramSource>();
public List<DisabledProgramSource> DisabledProgramSources { get; set; } = new List<DisabledProgramSource>();

[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<string>(); // Custom suffixes only
public string[] CustomProtocols { get; set; } = Array.Empty<string>();
Expand Down Expand Up @@ -111,6 +112,8 @@ private void RemoveRedundantSuffixes()
public bool EnableDescription { get; set; } = false;
public bool HideAppsPath { get; set; } = true;
public bool EnableRegistrySource { get; set; } = true;
public bool EnablePATHSource { get; set; } = true;

public string CustomizedExplorer { get; set; } = Explorer;
public string CustomizedArgs { get; set; } = ExplorerArgs;

Expand Down
167 changes: 67 additions & 100 deletions Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,58 +10,88 @@
mc:Ignorable="d">
<Grid Margin="0">
<Grid.RowDefinitions>
<RowDefinition Height="170" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="60" />
</Grid.RowDefinitions>
<DockPanel
Margin="70,10,0,8"
HorizontalAlignment="Stretch"
LastChildFill="True">
<TextBlock
MinWidth="120"
Margin="0,5,10,0"
Text="{DynamicResource flowlauncher_plugin_program_index_source}" />
<WrapPanel
Width="Auto"
Margin="0,0,14,0"
HorizontalAlignment="Right"
DockPanel.Dock="Right">
<CheckBox
Name="StartMenuEnabled"
Margin="12,0,12,0"
Content="{DynamicResource flowlauncher_plugin_program_index_start}"
IsChecked="{Binding EnableStartMenuSource}"
ToolTip="{DynamicResource flowlauncher_plugin_program_index_start_tooltip}" />
<CheckBox
Name="RegistryEnabled"
Margin="12,0,12,0"
Content="{DynamicResource flowlauncher_plugin_program_index_registry}"
IsChecked="{Binding EnableRegistrySource}"
ToolTip="{DynamicResource flowlauncher_plugin_program_index_registry_tooltip}" />

<CheckBox
Name="PATHEnabled"
Margin="12,0,12,0"
Content="{DynamicResource flowlauncher_plugin_program_index_PATH}"
IsChecked="{Binding EnablePATHSource}"
ToolTip="{DynamicResource flowlauncher_plugin_program_index_PATH_tooltip}" />
</WrapPanel>
</DockPanel>

<StackPanel
Grid.Row="0"
Grid.Row="1"
HorizontalAlignment="Stretch"
Orientation="Vertical">
<StackPanel Width="Auto" Orientation="Vertical">
<StackPanel Width="Auto" Orientation="Horizontal">
<CheckBox
Name="StartMenuEnabled"
Width="220"
Margin="70,8,10,8"
Content="{DynamicResource flowlauncher_plugin_program_index_start}"
IsChecked="{Binding EnableStartMenuSource}"
ToolTip="{DynamicResource flowlauncher_plugin_program_index_start_tooltip}" />
<CheckBox
Name="RegistryEnabled"
Margin="70,8,10,8"
Content="{DynamicResource flowlauncher_plugin_program_index_registry}"
IsChecked="{Binding EnableRegistrySource}"
ToolTip="{DynamicResource flowlauncher_plugin_program_index_registry_tooltip}" />
</StackPanel>

<Separator
Height="1"
BorderBrush="{DynamicResource Color03B}"
BorderThickness="1" />
<StackPanel Width="Auto" Orientation="Horizontal">
<Separator
Height="1"
BorderBrush="{DynamicResource Color03B}"
BorderThickness="1" />
<DockPanel
Margin="70,10,0,8"
HorizontalAlignment="Stretch"
LastChildFill="True">
<TextBlock
MinWidth="120"
Margin="0,5,10,0"
Text="{DynamicResource flowlauncher_plugin_program_index_option}" />
<WrapPanel
Width="Auto"
Margin="0,0,14,0"
HorizontalAlignment="Right"
DockPanel.Dock="Right">
<CheckBox
Name="HideLnkEnabled"
Width="220"
Margin="70,8,10,8"
Margin="12,0,12,0"
Content="{DynamicResource flowlauncher_plugin_program_enable_hidelnkpath}"
IsChecked="{Binding HideAppsPath}"
ToolTip="{DynamicResource flowlauncher_plugin_program_enable_hidelnkpath_tooltip}" />
<CheckBox
Name="DescriptionEnabled"
Margin="70,8,10,8"
Margin="12,0,12,0"
Content="{DynamicResource flowlauncher_plugin_program_enable_description}"
IsChecked="{Binding EnableDescription}"
ToolTip="{DynamicResource flowlauncher_plugin_program_enable_description_tooltip}" />
</StackPanel>
<Separator
Height="1"
BorderBrush="{DynamicResource Color03B}"
BorderThickness="1" />
</StackPanel>
</WrapPanel>
</DockPanel>
<Separator
Height="1"
BorderBrush="{DynamicResource Color03B}"
BorderThickness="1" />
<StackPanel
Width="Auto"
Margin="10,6,0,0"
Margin="60,6,0,0"
HorizontalAlignment="Left"
Orientation="Horizontal">
<Button
Expand Down Expand Up @@ -107,8 +137,8 @@
</StackPanel>
<ListView
x:Name="programSourceView"
Grid.Row="1"
Margin="20,0,20,0"
Grid.Row="2"
Margin="70,0,20,0"
AllowDrop="True"
BorderBrush="DarkGray"
BorderThickness="1"
Expand Down Expand Up @@ -147,7 +177,7 @@
</ListView.View>
</ListView>
<DockPanel
Grid.Row="2"
Grid.Row="3"
Grid.RowSpan="1"
Margin="0,0,20,10">
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
Expand All @@ -173,66 +203,3 @@
</DockPanel>
</Grid>
</UserControl>































































14 changes: 12 additions & 2 deletions Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -66,6 +66,16 @@ public bool EnableStartMenuSource
}
}

public bool EnablePATHSource
{
get => _settings.EnablePATHSource;
set
{
_settings.EnablePATHSource = value;
ReIndexing();
}
}

public string CustomizedExplorerPath
{
get => _settings.CustomizedExplorer;
Expand Down Expand Up @@ -360,4 +370,4 @@ private void Row_OnClick(object sender, RoutedEventArgs e)
}
}
}
}
}