Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
<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_hideuninstallers">Hide uninstallers</system:String>
<system:String x:Key="flowlauncher_plugin_program_enable_hideuninstallers_tooltip">Hides programs with common uninstaller names, such as unins000.exe</system:String>
<system:String x:Key="flowlauncher_plugin_program_enable_description">Search in Program Description</system:String>
<system:String x:Key="flowlauncher_plugin_program_enable_description_tooltip">Flow will search program's description</system:String>
<system:String x:Key="flowlauncher_plugin_program_suffixes_header">Suffixes</system:String>
Expand Down Expand Up @@ -92,4 +94,4 @@
<system:String x:Key="flowlauncher_plugin_program_run_as_administrator_not_supported_message">This app is not intended to be run as administrator</system:String>
<system:String x:Key="flowlauncher_plugin_program_run_failed">Unable to run {0}</system:String>

</ResourceDictionary>
</ResourceDictionary>
23 changes: 23 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Program/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Flow.Launcher.Plugin.Program.Views;
using Flow.Launcher.Plugin.Program.Views.Models;
using Microsoft.Extensions.Caching.Memory;
using Path = System.IO.Path;
using Stopwatch = Flow.Launcher.Infrastructure.Stopwatch;

namespace Flow.Launcher.Plugin.Program
Expand All @@ -33,6 +34,17 @@ public class Main : ISettingProvider, IAsyncPlugin, IPluginI18n, IContextMenu, I
private static readonly MemoryCacheOptions cacheOptions = new() { SizeLimit = 1560 };
private static MemoryCache cache = new(cacheOptions);

private static readonly string[] commonUninstallerNames =
{
"uninst.exe",
"unins000.exe",
"uninst000.exe",
"uninstall.exe"
};
// For cases when the uninstaller is named like "Uninstall Program Name.exe"
private const string CommonUninstallerPrefix = "uninstall";
private const string CommonUninstallerSuffix = ".exe";

static Main()
{
}
Expand All @@ -52,6 +64,7 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
.Concat(_uwps)
.AsParallel()
.WithCancellation(token)
.Where(HideUninstallersFilter)
.Where(p => p.Enabled)
.Select(p => p.Result(query.Search, Context.API))
.Where(r => r?.Score > 0)
Expand All @@ -68,6 +81,16 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
return result;
}

private bool HideUninstallersFilter(IProgram program)
{
if (!_settings.HideUninstallers) return true;
if (program is not Win32 win32) return true;
var fileName = Path.GetFileName(win32.ExecutablePath);
return !commonUninstallerNames.Contains(fileName, StringComparer.OrdinalIgnoreCase) &&
!(fileName.StartsWith(CommonUninstallerPrefix, StringComparison.OrdinalIgnoreCase) &&
fileName.EndsWith(CommonUninstallerSuffix, StringComparison.OrdinalIgnoreCase));
}

public async Task InitAsync(PluginInitContext context)
{
Context = context;
Expand Down
3 changes: 2 additions & 1 deletion Plugins/Flow.Launcher.Plugin.Program/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void RemoveRedundantSuffixes()
// CustomSuffixes no longer contains custom suffixes
// users has tweaked the settings
// or this function has been executed once
if (UseCustomSuffixes == true || ProgramSuffixes == null)
if (UseCustomSuffixes == true || ProgramSuffixes == null)
return;
var suffixes = ProgramSuffixes.ToList();
foreach(var item in BuiltinSuffixesStatus)
Expand All @@ -117,6 +117,7 @@ private void RemoveRedundantSuffixes()
public bool EnableStartMenuSource { get; set; } = true;
public bool EnableDescription { get; set; } = false;
public bool HideAppsPath { get; set; } = true;
public bool HideUninstallers { get; set; } = false;
public bool EnableRegistrySource { get; set; } = true;
public bool EnablePathSource { get; set; } = false;
public bool EnableUWP { get; set; } = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@
Content="{DynamicResource flowlauncher_plugin_program_enable_hidelnkpath}"
IsChecked="{Binding HideAppsPath}"
ToolTip="{DynamicResource flowlauncher_plugin_program_enable_hidelnkpath_tooltip}" />
<CheckBox
Margin="12 0 12 0"
Content="{DynamicResource flowlauncher_plugin_program_enable_hideuninstallers}"
IsChecked="{Binding HideUninstallers}"
ToolTip="{DynamicResource flowlauncher_plugin_program_enable_hideuninstallers_tooltip}" />
<CheckBox
Name="DescriptionEnabled"
Margin="12,0,12,0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public partial class ProgramSetting : UserControl
private ListSortDirection _lastDirection;

// We do not save all program sources to settings, so using
// this as temporary holder for displaying all loaded programs sources.
// this as temporary holder for displaying all loaded programs sources.
internal static List<ProgramSource> ProgramSettingDisplayList { get; set; }

public bool EnableDescription
Expand All @@ -47,6 +47,16 @@ public bool HideAppsPath
}
}

public bool HideUninstallers
{
get => _settings.HideUninstallers;
set
{
Main.ResetCache();
_settings.HideUninstallers = value;
}
}

public bool EnableRegistrySource
{
get => _settings.EnableRegistrySource;
Expand Down