Skip to content
Merged
Changes from 1 commit
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
12 changes: 9 additions & 3 deletions Plugins/Flow.Launcher.Plugin.Sys/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{"Lock", "flowlauncher_plugin_sys_lock_cmd"},
{"Sleep", "flowlauncher_plugin_sys_sleep_cmd"},
{"Hibernate", "flowlauncher_plugin_sys_hibernate_cmd"},
{"Index Option", "flowlauncher_plugin_sys_indexoption_cmd"},

Check warning on line 32 in Plugins/Flow.Launcher.Plugin.Sys/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`indexoption` is not a recognized word. (unrecognized-spelling)
{"Empty Recycle Bin", "flowlauncher_plugin_sys_emptyrecyclebin_cmd"},
{"Open Recycle Bin", "flowlauncher_plugin_sys_openrecyclebin_cmd"},
{"Exit", "flowlauncher_plugin_sys_exit_cmd"},
Expand Down Expand Up @@ -70,13 +70,19 @@
return _themeSelector.Query(query);
}

var commands = Commands();
var commands = Commands(query);
var results = new List<Result>();
var isEmptyQuery = string.IsNullOrEmpty(query.Search) || string.IsNullOrWhiteSpace(query.Search);
foreach (var c in commands)
{
var command = _settings.Commands.First(x => x.Key == c.Title);
c.Title = command.Name;
c.SubTitle = command.Description;
if (isEmptyQuery)
{
results.Add(c);
continue;
}

// Match from localized title & localized subtitle & keyword
var titleMatch = _context.API.FuzzySearch(query.Search, c.Title);
Expand Down Expand Up @@ -159,7 +165,7 @@
return false;
}

if (!PInvoke.LookupPrivilegeValue(null, PInvoke.SE_SHUTDOWN_NAME, out var luid))

Check warning on line 168 in Plugins/Flow.Launcher.Plugin.Sys/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`PInvoke` is not a recognized word. (unrecognized-spelling)

Check warning on line 168 in Plugins/Flow.Launcher.Plugin.Sys/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`PInvoke` is not a recognized word. (unrecognized-spelling)
{
return false;
}
Expand All @@ -170,7 +176,7 @@
Privileges = new() { e0 = new LUID_AND_ATTRIBUTES { Luid = luid, Attributes = TOKEN_PRIVILEGES_ATTRIBUTES.SE_PRIVILEGE_ENABLED } }
};

if (!PInvoke.AdjustTokenPrivileges(tokenHandle, false, &privileges, 0, null, null))

Check warning on line 179 in Plugins/Flow.Launcher.Plugin.Sys/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`PInvoke` is not a recognized word. (unrecognized-spelling)
{
return false;
}
Expand All @@ -188,7 +194,7 @@
}
}

private List<Result> Commands()
private List<Result> Commands(Query query)
{
var results = new List<Result>();
var recycleBinFolder = "shell:RecycleBinFolder";
Expand All @@ -208,7 +214,7 @@

if (result == MessageBoxResult.Yes)
if (EnableShutdownPrivilege())
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_SHUTDOWN | EXIT_WINDOWS_FLAGS.EWX_POWEROFF, REASON);

Check warning on line 217 in Plugins/Flow.Launcher.Plugin.Sys/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`PInvoke` is not a recognized word. (unrecognized-spelling)
else
Process.Start("shutdown", "/s /t 0");

Expand Down Expand Up @@ -311,7 +317,7 @@
new Result
{
Title = "Index Option",
IcoPath = "Images\\indexoption.png",

Check warning on line 320 in Plugins/Flow.Launcher.Plugin.Sys/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`indexoption` is not a recognized word. (unrecognized-spelling)
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe773"),
Action = c =>
{
Expand Down Expand Up @@ -346,7 +352,7 @@
new Result
{
Title = "Open Recycle Bin",
IcoPath = "Images\\openrecyclebin.png",

Check warning on line 355 in Plugins/Flow.Launcher.Plugin.Sys/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`openrecyclebin` is not a recognized word. (unrecognized-spelling)
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe74d"),
CopyText = recycleBinFolder,
Action = c =>
Expand Down Expand Up @@ -414,7 +420,7 @@

_ = _context.API.ReloadAllPluginData().ContinueWith(_ =>
_context.API.ShowMsg(
_context.API.GetTranslation("flowlauncher_plugin_sys_dlgtitle_success"),

Check warning on line 423 in Plugins/Flow.Launcher.Plugin.Sys/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`dlgtitle` is not a recognized word. (unrecognized-spelling)
_context.API.GetTranslation(
"flowlauncher_plugin_sys_dlgtext_all_applicableplugins_reloaded")),
System.Threading.Tasks.TaskScheduler.Current);
Expand Down Expand Up @@ -491,7 +497,7 @@
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\ue790"),
Action = c =>
{
_context.API.ChangeQuery($"{ThemeSelector.Keyword} ");
_context.API.ChangeQuery($"{query.ActionKeyword}{ (string.IsNullOrEmpty(query.ActionKeyword) ? string.Empty : Plugin.Query.ActionKeywordSeparator)}{ThemeSelector.Keyword}{Plugin.Query.ActionKeywordSeparator}");
return false;
}
}
Expand Down
Loading