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
9 changes: 9 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Sys/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
return false;
}

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

Check warning on line 167 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 167 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 @@ -175,7 +175,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 178 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 Down Expand Up @@ -211,9 +211,12 @@
Localize.flowlauncher_plugin_sys_shutdown_computer(),
MessageBoxButton.YesNo, MessageBoxImage.Warning);

// Save settings before shutdown to avoid data loss
Context.API.SaveAppAllSettings();

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

Check warning on line 219 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 All @@ -232,6 +235,9 @@
Localize.flowlauncher_plugin_sys_restart_computer(),
MessageBoxButton.YesNo, MessageBoxImage.Warning);

// Save settings before restart to avoid data loss
Context.API.SaveAppAllSettings();

if (result == MessageBoxResult.Yes)
if (EnableShutdownPrivilege())
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT, REASON);
Expand All @@ -253,6 +259,9 @@
Localize.flowlauncher_plugin_sys_restart_computer(),
MessageBoxButton.YesNo, MessageBoxImage.Warning);

// Save settings before restart to avoid data loss
Context.API.SaveAppAllSettings();

if (result == MessageBoxResult.Yes)
if (EnableShutdownPrivilege())
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT | EXIT_WINDOWS_FLAGS.EWX_BOOTOPTIONS, REASON);
Expand Down Expand Up @@ -316,7 +325,7 @@
new Result
{
Title = "Index Option",
IcoPath = "Images\\indexoption.png",

Check warning on line 328 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 @@ -349,7 +358,7 @@
new Result
{
Title = "Open Recycle Bin",
IcoPath = "Images\\openrecyclebin.png",

Check warning on line 361 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 @@ -378,7 +387,7 @@
Action = c =>
{
Context.API.SaveAppAllSettings();
Context.API.ShowMsg(Localize.flowlauncher_plugin_sys_dlgtitle_success(),

Check warning on line 390 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)
Localize.flowlauncher_plugin_sys_dlgtext_all_settings_saved());
return true;
}
Expand Down Expand Up @@ -419,7 +428,7 @@

_ = Context.API.ReloadAllPluginData().ContinueWith(_ =>
Context.API.ShowMsg(
Localize.flowlauncher_plugin_sys_dlgtitle_success(),

Check warning on line 431 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)
Localize.flowlauncher_plugin_sys_dlgtext_all_applicableplugins_reloaded()),
TaskScheduler.Current);

Expand Down
Loading