Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">

<!-- Setting -->
<system:String x:Key="flowlauncher_plugin_sys_skip_confirm">Skip confirmation when Shutting down, Restarting, or Logging off</system:String>

Comment thread
Jack251970 marked this conversation as resolved.
<!-- Command List -->
<system:String x:Key="flowlauncher_plugin_sys_name">Name</system:String>
<system:String x:Key="flowlauncher_plugin_sys_desc">Description</system:String>
Expand Down
76 changes: 42 additions & 34 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, null, out var _))

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 All @@ -193,7 +193,7 @@
}
}

private static List<Result> Commands(Query query)
private List<Result> Commands(Query query)
{
var results = new List<Result>();
var recycleBinFolder = "shell:RecycleBinFolder";
Expand All @@ -206,22 +206,23 @@
IcoPath = "Images\\shutdown.png",
Action = c =>
{
var result = Context.API.ShowMsgBox(
Localize.flowlauncher_plugin_sys_dlgtext_shutdown_computer(),
Localize.flowlauncher_plugin_sys_shutdown_computer(),
MessageBoxButton.YesNo, MessageBoxImage.Warning);
MessageBoxResult result = _settings.SkipPowerActionConfirmation
? MessageBoxResult.Yes
: Context.API.ShowMsgBox(
Localize.flowlauncher_plugin_sys_dlgtext_shutdown_computer(),
Localize.flowlauncher_plugin_sys_shutdown_computer(),
MessageBoxButton.YesNo, MessageBoxImage.Warning);

if (result == MessageBoxResult.Yes)
{
// Save settings before shutdown to avoid data loss
Context.API.SaveAppAllSettings();

if (EnableShutdownPrivilege())
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_SHUTDOWN | EXIT_WINDOWS_FLAGS.EWX_POWEROFF, REASON);

Check warning on line 220 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");
}
return true;
}
}
},
Comment thread
Jack251970 marked this conversation as resolved.
new Result
{
Expand All @@ -230,21 +231,22 @@
IcoPath = "Images\\restart.png",
Action = c =>
{
var result = Context.API.ShowMsgBox(
Localize.flowlauncher_plugin_sys_dlgtext_restart_computer(),
Localize.flowlauncher_plugin_sys_restart_computer(),
MessageBoxButton.YesNo, MessageBoxImage.Warning);
if (result == MessageBoxResult.Yes)
{
// Save settings before restart to avoid data loss
Context.API.SaveAppAllSettings();

if (EnableShutdownPrivilege())
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT, REASON);
else
Process.Start("shutdown", "/r /t 0");
}
return true;
MessageBoxResult result = _settings.SkipPowerActionConfirmation
? MessageBoxResult.Yes
: Context.API.ShowMsgBox(
Localize.flowlauncher_plugin_sys_dlgtext_restart_computer(),
Localize.flowlauncher_plugin_sys_restart_computer(),
MessageBoxButton.YesNo, MessageBoxImage.Warning);

if (result == MessageBoxResult.Yes)
{
Context.API.SaveAppAllSettings();
if (EnableShutdownPrivilege())
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT, REASON);
else
Process.Start("shutdown", "/r /t 0");
}
return true;
}
},
new Result
Expand All @@ -254,10 +256,13 @@
IcoPath = "Images\\restart_advanced.png",
Action = c =>
{
var result = Context.API.ShowMsgBox(
Localize.flowlauncher_plugin_sys_dlgtext_restart_computer_advanced(),
Localize.flowlauncher_plugin_sys_restart_computer(),
MessageBoxButton.YesNo, MessageBoxImage.Warning);
var result = _settings.SkipPowerActionConfirmation
? MessageBoxResult.Yes
: Context.API.ShowMsgBox(
Localize.flowlauncher_plugin_sys_dlgtext_restart_computer_advanced(),
Localize.flowlauncher_plugin_sys_restart_computer(),
MessageBoxButton.YesNo, MessageBoxImage.Warning);

if (result == MessageBoxResult.Yes)
{
// Save settings before advanced restart to avoid data loss
Expand All @@ -278,13 +283,16 @@
IcoPath = "Images\\logoff.png",
Action = c =>
{
var result = Context.API.ShowMsgBox(
Localize.flowlauncher_plugin_sys_dlgtext_logoff_computer(),
Localize.flowlauncher_plugin_sys_log_off(),
MessageBoxButton.YesNo, MessageBoxImage.Warning);
if (result == MessageBoxResult.Yes)
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_LOGOFF, REASON);
return true;
MessageBoxResult result = _settings.SkipPowerActionConfirmation
? MessageBoxResult.Yes
: Context.API.ShowMsgBox(
Localize.flowlauncher_plugin_sys_dlgtext_logoff_computer(),
Localize.flowlauncher_plugin_sys_log_off(),
MessageBoxButton.YesNo, MessageBoxImage.Warning);

if (result == MessageBoxResult.Yes)
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_LOGOFF, REASON);
return true;
Comment thread
Jack251970 marked this conversation as resolved.
Outdated
}
},
new Result
Expand Down Expand Up @@ -323,7 +331,7 @@
new Result
{
Title = "Index Option",
IcoPath = "Images\\indexoption.png",

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

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

Check warning on line 395 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 @@ -424,7 +432,7 @@
Context.API.HideMainWindow();
_ = Context.API.ReloadAllPluginData().ContinueWith(_ =>
Context.API.ShowMsg(
Localize.flowlauncher_plugin_sys_dlgtitle_success(),

Check warning on line 435 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);
return true;
Expand Down
9 changes: 9 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Sys/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,13 @@ public Settings()

[JsonIgnore]
public Command SelectedCommand { get; set; }
private bool _skipPowerActionConfirmation;
public bool SkipPowerActionConfirmation
{
get => _skipPowerActionConfirmation;
set
{
_skipPowerActionConfirmation = value;
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Comment thread
onesounds marked this conversation as resolved.
}
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
2 changes: 2 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Sys/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ public class SettingsViewModel(Settings settings)
{
public Settings Settings { get; } = settings;
}


}
13 changes: 10 additions & 3 deletions Plugins/Flow.Launcher.Plugin.Sys/SysSettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@

<Grid Margin="{StaticResource SettingPanelMargin}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<StackPanel
Grid.Row="0"
Margin="0 0 0 6"
HorizontalAlignment="Left"
Orientation="Horizontal">
<CheckBox Content="{DynamicResource flowlauncher_plugin_sys_skip_confirm}" IsChecked="{Binding Settings.SkipPowerActionConfirmation}" />
</StackPanel>
Comment thread
Jack251970 marked this conversation as resolved.
<ListView
x:Name="lbxCommands"
Grid.Row="0"
Grid.Row="1"
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
BorderBrush="DarkGray"
BorderThickness="1"
Expand Down Expand Up @@ -57,7 +64,7 @@
</ListView>

<StackPanel
Grid.Row="1"
Grid.Row="2"
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
HorizontalAlignment="Right"
Orientation="Horizontal">
Expand Down
Loading