2022-08-08 04:31:38 +00:00
using System ;
2015-11-26 01:27:18 +00:00
using System.Collections.Generic ;
2014-07-25 00:32:19 +00:00
using System.Diagnostics ;
2025-03-13 15:29:00 +00:00
using System.Globalization ;
2025-03-13 15:43:01 +00:00
using System.Linq ;
2025-02-17 16:08:15 +00:00
using System.Runtime.InteropServices ;
2025-09-27 16:18:33 +00:00
using System.Threading.Tasks ;
2015-11-26 01:27:18 +00:00
using System.Windows ;
2024-12-10 03:56:32 +00:00
using Windows.Win32 ;
using Windows.Win32.Foundation ;
2025-02-17 16:08:15 +00:00
using Windows.Win32.Security ;
2024-12-10 03:56:32 +00:00
using Windows.Win32.System.Shutdown ;
2016-01-06 06:45:08 +00:00
using Application = System . Windows . Application ;
2015-07-14 15:59:24 +00:00
using Control = System . Windows . Controls . Control ;
2014-07-25 00:32:19 +00:00
2020-04-21 09:12:17 +00:00
namespace Flow.Launcher.Plugin.Sys
2014-07-25 00:32:19 +00:00
{
2025-03-12 13:50:39 +00:00
public class Main : IPlugin , ISettingProvider , IPluginI18n
2015-02-27 10:04:49 +00:00
{
2025-04-09 04:14:07 +00:00
private static readonly string ClassName = nameof ( Main ) ;
2025-03-13 14:34:50 +00:00
private readonly Dictionary < string , string > KeywordTitleMappings = new ( )
{
{ "Shutdown" , "flowlauncher_plugin_sys_shutdown_computer_cmd" } ,
{ "Restart" , "flowlauncher_plugin_sys_restart_computer_cmd" } ,
{ "Restart With Advanced Boot Options" , "flowlauncher_plugin_sys_restart_advanced_cmd" } ,
{ "Log Off/Sign Out" , "flowlauncher_plugin_sys_log_off_cmd" } ,
{ "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" } ,
{ "Empty Recycle Bin" , "flowlauncher_plugin_sys_emptyrecyclebin_cmd" } ,
{ "Open Recycle Bin" , "flowlauncher_plugin_sys_openrecyclebin_cmd" } ,
{ "Exit" , "flowlauncher_plugin_sys_exit_cmd" } ,
{ "Save Settings" , "flowlauncher_plugin_sys_save_all_settings_cmd" } ,
{ "Restart Flow Launcher" , "flowlauncher_plugin_sys_restart_cmd" } ,
{ "Settings" , "flowlauncher_plugin_sys_setting_cmd" } ,
{ "Reload Plugin Data" , "flowlauncher_plugin_sys_reload_plugin_data_cmd" } ,
{ "Check For Update" , "flowlauncher_plugin_sys_check_for_update_cmd" } ,
{ "Open Log Location" , "flowlauncher_plugin_sys_open_log_location_cmd" } ,
{ "Flow Launcher Tips" , "flowlauncher_plugin_sys_open_docs_tips_cmd" } ,
{ "Flow Launcher UserData Folder" , "flowlauncher_plugin_sys_open_userdata_location_cmd" } ,
{ "Toggle Game Mode" , "flowlauncher_plugin_sys_toggle_game_mode_cmd" } ,
{ "Set Flow Launcher Theme" , "flowlauncher_plugin_sys_theme_selector_cmd" }
} ;
2025-09-27 16:18:33 +00:00
private readonly Dictionary < string , string > KeywordDescriptionMappings = [ ] ;
2025-03-13 14:34:50 +00:00
2025-03-13 15:29:00 +00:00
// SHTDN_REASON_MAJOR_OTHER indicates a generic shutdown reason that isn't categorized under hardware failure,
// software updates, or other predefined reasons.
2025-02-18 03:07:18 +00:00
// SHTDN_REASON_FLAG_PLANNED marks the shutdown as planned rather than an unexpected shutdown or failure
2025-03-13 15:29:00 +00:00
private const SHUTDOWN_REASON REASON = SHUTDOWN_REASON . SHTDN_REASON_MAJOR_OTHER |
SHUTDOWN_REASON . SHTDN_REASON_FLAG_PLANNED ;
2025-07-20 01:58:30 +00:00
private const string Documentation = "https://flowlauncher.com/docs/#/usage-tips" ;
2025-09-27 16:18:33 +00:00
internal static PluginInitContext Context { get ; private set ; }
2025-03-13 15:29:00 +00:00
private Settings _settings ;
private SettingsViewModel _viewModel ;
2025-02-17 16:08:15 +00:00
2015-07-14 15:59:24 +00:00
public Control CreateSettingPanel ( )
2014-07-25 00:32:19 +00:00
{
2025-03-13 14:34:50 +00:00
UpdateLocalizedNameDescription ( false ) ;
2025-09-27 16:18:33 +00:00
return new SysSettings ( _viewModel ) ;
2014-07-25 00:32:19 +00:00
}
2015-01-03 07:20:34 +00:00
public List < Result > Query ( Query query )
2014-07-25 00:32:19 +00:00
{
2025-09-27 16:18:33 +00:00
if ( query . Search . StartsWith ( ThemeSelector . Keyword ) )
2024-06-15 11:16:36 +00:00
{
2025-09-27 16:18:33 +00:00
return ThemeSelector . Query ( query ) ;
2024-06-15 11:16:36 +00:00
}
2025-07-15 13:22:19 +00:00
var commands = Commands ( query ) ;
2017-02-21 02:19:50 +00:00
var results = new List < Result > ( ) ;
2025-07-15 13:50:41 +00:00
var isEmptyQuery = string . IsNullOrWhiteSpace ( query . Search ) ;
2017-02-21 02:19:50 +00:00
foreach ( var c in commands )
2014-07-25 00:32:19 +00:00
{
2025-03-13 15:43:01 +00:00
var command = _settings . Commands . First ( x = > x . Key = = c . Title ) ;
c . Title = command . Name ;
c . SubTitle = command . Description ;
2025-07-15 13:22:19 +00:00
if ( isEmptyQuery )
{
results . Add ( c ) ;
continue ;
}
2024-01-15 15:16:07 +00:00
2025-03-14 07:32:23 +00:00
// Match from localized title & localized subtitle & keyword
2025-09-27 16:18:33 +00:00
var titleMatch = Context . API . FuzzySearch ( query . Search , c . Title ) ;
var subTitleMatch = Context . API . FuzzySearch ( query . Search , c . SubTitle ) ;
var keywordMatch = Context . API . FuzzySearch ( query . Search , command . Keyword ) ;
2025-03-13 15:57:52 +00:00
2025-03-14 07:32:23 +00:00
// Get the largest score from them
2025-03-13 15:57:52 +00:00
var score = Math . Max ( titleMatch . Score , subTitleMatch . Score ) ;
2025-03-14 07:32:23 +00:00
var finalScore = Math . Max ( score , keywordMatch . Score ) ;
if ( finalScore > 0 )
2025-03-13 15:57:52 +00:00
{
2025-03-14 07:32:23 +00:00
c . Score = finalScore ;
2025-03-13 15:57:52 +00:00
2025-03-14 07:32:23 +00:00
// If title match has the highest score, highlight title
if ( finalScore = = titleMatch . Score )
{
2025-03-13 15:57:52 +00:00
c . TitleHighlightData = titleMatch . MatchData ;
2025-03-14 07:32:23 +00:00
}
2021-12-20 20:19:31 +00:00
2017-02-21 02:19:50 +00:00
results . Add ( c ) ;
2014-07-25 00:32:19 +00:00
}
}
2021-01-02 07:52:41 +00:00
2014-07-25 00:32:19 +00:00
return results ;
}
2025-03-13 14:34:50 +00:00
private string GetTitle ( string key )
{
if ( ! KeywordTitleMappings . TryGetValue ( key , out var translationKey ) )
{
2025-09-27 16:18:33 +00:00
Context . API . LogError ( ClassName , $"Title not found for: {key}" ) ;
2025-03-13 14:34:50 +00:00
return "Title Not Found" ;
}
2025-09-27 16:18:33 +00:00
return Context . API . GetTranslation ( translationKey ) ;
2025-03-13 14:34:50 +00:00
}
private string GetDescription ( string key )
{
if ( ! KeywordDescriptionMappings . TryGetValue ( key , out var translationKey ) )
{
2025-09-27 16:18:33 +00:00
Context . API . LogError ( ClassName , $"Description not found for: {key}" ) ;
2025-03-13 14:34:50 +00:00
return "Description Not Found" ;
}
2025-09-27 16:18:33 +00:00
return Context . API . GetTranslation ( translationKey ) ;
2025-03-13 14:34:50 +00:00
}
2015-01-03 07:20:34 +00:00
public void Init ( PluginInitContext context )
2014-07-25 00:32:19 +00:00
{
2025-09-27 16:18:33 +00:00
Context = context ;
2025-03-13 15:29:00 +00:00
_settings = context . API . LoadSettingJsonStorage < Settings > ( ) ;
_viewModel = new SettingsViewModel ( _settings ) ;
2025-03-13 14:34:50 +00:00
foreach ( string key in KeywordTitleMappings . Keys )
{
// Remove _cmd in the last of the strings
KeywordDescriptionMappings [ key ] = KeywordTitleMappings [ key ] [ . . ^ 4 ] ;
}
}
private void UpdateLocalizedNameDescription ( bool force )
{
2025-03-13 15:29:00 +00:00
if ( string . IsNullOrEmpty ( _settings . Commands [ 0 ] . Name ) | | force )
2025-03-13 14:34:50 +00:00
{
2025-03-13 15:29:00 +00:00
foreach ( var c in _settings . Commands )
2025-03-13 14:34:50 +00:00
{
c . Name = GetTitle ( c . Key ) ;
c . Description = GetDescription ( c . Key ) ;
}
}
2015-01-07 14:23:10 +00:00
}
2025-02-17 16:08:15 +00:00
private static unsafe bool EnableShutdownPrivilege ( )
{
try
{
if ( ! PInvoke . OpenProcessToken ( Process . GetCurrentProcess ( ) . SafeHandle , TOKEN_ACCESS_MASK . TOKEN_ADJUST_PRIVILEGES | TOKEN_ACCESS_MASK . TOKEN_QUERY , out var tokenHandle ) )
{
return false ;
}
2025-02-18 03:12:33 +00:00
if ( ! PInvoke . LookupPrivilegeValue ( null , PInvoke . SE_SHUTDOWN_NAME , out var luid ) )
2025-02-17 16:08:15 +00:00
{
return false ;
}
var privileges = new TOKEN_PRIVILEGES
{
PrivilegeCount = 1 ,
Privileges = new ( ) { e0 = new LUID_AND_ATTRIBUTES { Luid = luid , Attributes = TOKEN_PRIVILEGES_ATTRIBUTES . SE_PRIVILEGE_ENABLED } }
} ;
2026-02-05 12:28:37 +00:00
if ( ! PInvoke . AdjustTokenPrivileges ( tokenHandle , false , & privileges , null , out var _ ) )
2025-02-17 16:08:15 +00:00
{
return false ;
}
if ( Marshal . GetLastWin32Error ( ) ! = ( int ) WIN32_ERROR . NO_ERROR )
{
return false ;
}
return true ;
}
catch ( Exception )
{
return false ;
}
}
2026-02-20 08:18:21 +00:00
private List < Result > Commands ( Query query )
2015-01-07 14:23:10 +00:00
{
2017-02-21 02:19:50 +00:00
var results = new List < Result > ( ) ;
2024-12-07 22:45:32 +00:00
var recycleBinFolder = "shell:RecycleBinFolder" ;
2025-09-27 16:18:33 +00:00
results . AddRange (
[
2015-11-08 11:21:48 +00:00
new Result
{
2024-01-15 15:16:07 +00:00
Title = "Shutdown" ,
2021-10-07 10:58:54 +00:00
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe7e8" ) ,
IcoPath = "Images\\shutdown.png" ,
2016-01-06 21:34:42 +00:00
Action = c = >
2015-11-08 11:21:48 +00:00
{
2026-02-21 06:51:20 +00:00
var result = _settings . SkipPowerActionConfirmation
2026-02-20 08:18:21 +00:00
? MessageBoxResult . Yes
: Context . API . ShowMsgBox (
Localize . flowlauncher_plugin_sys_dlgtext_shutdown_computer ( ) ,
Localize . flowlauncher_plugin_sys_shutdown_computer ( ) ,
MessageBoxButton . YesNo , MessageBoxImage . Warning ) ;
2022-12-31 15:43:07 +00:00
if ( result = = MessageBoxResult . Yes )
2025-10-02 11:42:24 +00:00
{
Context . API . SaveAppAllSettings ( ) ;
2025-02-17 16:08:15 +00:00
if ( EnableShutdownPrivilege ( ) )
2025-02-18 03:07:18 +00:00
PInvoke . ExitWindowsEx ( EXIT_WINDOWS_FLAGS . EWX_SHUTDOWN | EXIT_WINDOWS_FLAGS . EWX_POWEROFF , REASON ) ;
2025-02-17 16:08:15 +00:00
else
Process . Start ( "shutdown" , "/s /t 0" ) ;
2025-10-02 11:42:24 +00:00
}
2015-11-08 11:21:48 +00:00
return true ;
2026-02-20 08:34:37 +00:00
}
2015-11-08 11:21:48 +00:00
} ,
new Result
2015-11-25 17:49:44 +00:00
{
2024-01-15 15:16:07 +00:00
Title = "Restart" ,
2021-10-07 10:58:54 +00:00
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe777" ) ,
IcoPath = "Images\\restart.png" ,
2016-01-06 21:34:42 +00:00
Action = c = >
2015-11-25 17:49:44 +00:00
{
2026-02-21 06:51:20 +00:00
var result = _settings . SkipPowerActionConfirmation
2026-02-20 08:40:27 +00:00
? MessageBoxResult . Yes
: Context . API . ShowMsgBox (
Localize . flowlauncher_plugin_sys_dlgtext_restart_computer ( ) ,
Localize . flowlauncher_plugin_sys_restart_computer ( ) ,
MessageBoxButton . YesNo , MessageBoxImage . Warning ) ;
2025-10-02 11:42:24 +00:00
2026-02-20 08:34:37 +00:00
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 ;
2015-11-25 17:49:44 +00:00
}
} ,
new Result
2021-09-05 23:02:04 +00:00
{
2024-01-15 15:16:07 +00:00
Title = "Restart With Advanced Boot Options" ,
2021-10-07 10:58:54 +00:00
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xecc5" ) ,
IcoPath = "Images\\restart_advanced.png" ,
2021-09-05 23:02:04 +00:00
Action = c = >
{
2026-02-20 08:18:21 +00:00
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 ) ;
2021-09-05 23:02:04 +00:00
if ( result = = MessageBoxResult . Yes )
2025-10-02 11:42:24 +00:00
{
2025-10-02 11:45:08 +00:00
// Save settings before advanced restart to avoid data loss
2025-10-02 11:42:24 +00:00
Context . API . SaveAppAllSettings ( ) ;
2025-02-17 16:08:15 +00:00
if ( EnableShutdownPrivilege ( ) )
2025-02-18 03:07:18 +00:00
PInvoke . ExitWindowsEx ( EXIT_WINDOWS_FLAGS . EWX_REBOOT | EXIT_WINDOWS_FLAGS . EWX_BOOTOPTIONS , REASON ) ;
2025-02-17 16:08:15 +00:00
else
Process . Start ( "shutdown" , "/r /o /t 0" ) ;
2025-10-02 11:42:24 +00:00
}
2021-09-05 23:02:04 +00:00
return true ;
}
} ,
new Result
2015-11-08 11:21:48 +00:00
{
2024-01-15 15:16:07 +00:00
Title = "Log Off/Sign Out" ,
2021-10-07 10:58:54 +00:00
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe77b" ) ,
IcoPath = "Images\\logoff.png" ,
2022-12-31 03:54:55 +00:00
Action = c = >
{
2026-02-21 06:51:20 +00:00
var 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 ) ;
2026-02-20 08:18:21 +00:00
2026-02-21 06:51:20 +00:00
if ( result = = MessageBoxResult . Yes )
PInvoke . ExitWindowsEx ( EXIT_WINDOWS_FLAGS . EWX_LOGOFF , REASON ) ;
return true ;
2022-12-31 03:54:55 +00:00
}
2015-11-08 11:21:48 +00:00
} ,
new Result
{
2024-01-15 15:16:07 +00:00
Title = "Lock" ,
2021-10-07 10:58:54 +00:00
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe72e" ) ,
IcoPath = "Images\\lock.png" ,
2016-01-06 21:34:42 +00:00
Action = c = >
2015-11-08 11:21:48 +00:00
{
2024-12-10 03:56:32 +00:00
PInvoke . LockWorkStation ( ) ;
2015-11-08 11:21:48 +00:00
return true ;
}
2017-02-21 02:19:50 +00:00
} ,
2015-07-14 15:59:24 +00:00
new Result
{
2024-01-15 15:16:07 +00:00
Title = "Sleep" ,
2021-10-07 10:58:54 +00:00
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xec46" ) ,
IcoPath = "Images\\sleep.png" ,
2025-02-17 15:12:46 +00:00
Action = c = >
{
PInvoke . SetSuspendState ( false , false , false ) ;
return true ;
}
2015-11-25 17:49:44 +00:00
} ,
2015-11-26 01:27:18 +00:00
new Result
2019-09-30 10:03:06 +00:00
{
2024-01-15 15:16:07 +00:00
Title = "Hibernate" ,
2025-03-28 21:05:23 +00:00
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe8be" ) ,
2021-10-07 10:58:54 +00:00
IcoPath = "Images\\hibernate.png" ,
2021-03-04 08:51:56 +00:00
Action = c = >
{
2025-02-18 03:17:45 +00:00
PInvoke . SetSuspendState ( true , false , false ) ;
2021-03-04 08:51:56 +00:00
return true ;
}
2019-09-30 10:03:06 +00:00
} ,
2022-09-08 11:45:26 +00:00
new Result
{
2024-01-15 15:16:07 +00:00
Title = "Index Option" ,
2022-09-08 11:45:26 +00:00
IcoPath = "Images\\indexoption.png" ,
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe773" ) ,
Action = c = >
{
2025-02-17 15:12:46 +00:00
Process . Start ( "control.exe" , "srchadmin.dll" ) ;
2022-09-08 11:45:26 +00:00
return true ;
}
} ,
new Result
2015-11-25 17:49:44 +00:00
{
2024-01-15 15:16:07 +00:00
Title = "Empty Recycle Bin" ,
2021-10-07 10:58:54 +00:00
IcoPath = "Images\\recyclebin.png" ,
2025-03-28 21:05:23 +00:00
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xea99" ) ,
2016-01-06 21:34:42 +00:00
Action = c = >
2015-11-25 17:49:44 +00:00
{
2015-11-26 01:27:18 +00:00
// http://www.pinvoke.net/default.aspx/shell32/SHEmptyRecycleBin.html
2018-12-22 06:23:28 +00:00
// FYI, couldn't find documentation for this but if the recycle bin is already empty, it will return -2147418113 (0x8000FFFF (E_UNEXPECTED))
2015-11-26 01:27:18 +00:00
// 0 for nothing
2024-12-10 03:56:32 +00:00
var result = PInvoke . SHEmptyRecycleBin ( new ( ) , string . Empty , 0 ) ;
if ( result ! = HRESULT . S_OK & & result ! = HRESULT . E_UNEXPECTED )
2015-11-25 17:49:44 +00:00
{
2025-09-27 16:18:33 +00:00
Context . API . ShowMsgBox (
Localize . flowlauncher_plugin_sys_dlgtext_empty_recycle_bin_failed ( Environment . NewLine ) ,
Localize . flowlauncher_plugin_sys_dlgtitle_error ( ) ,
2021-01-02 07:52:41 +00:00
MessageBoxButton . OK , MessageBoxImage . Error ) ;
2015-11-25 17:49:44 +00:00
}
return true ;
}
2015-07-14 15:59:24 +00:00
} ,
new Result
2022-09-08 08:43:25 +00:00
{
2024-01-15 15:16:07 +00:00
Title = "Open Recycle Bin" ,
2022-09-08 11:45:26 +00:00
IcoPath = "Images\\openrecyclebin.png" ,
2022-09-08 08:43:25 +00:00
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe74d" ) ,
2024-12-07 22:45:32 +00:00
CopyText = recycleBinFolder ,
2022-09-08 08:43:25 +00:00
Action = c = >
{
2025-02-17 15:12:46 +00:00
Process . Start ( "explorer" , recycleBinFolder ) ;
2022-09-08 08:43:25 +00:00
return true ;
}
} ,
new Result
2015-11-08 11:21:48 +00:00
{
2024-01-15 15:16:07 +00:00
Title = "Exit" ,
2015-11-08 11:21:48 +00:00
IcoPath = "Images\\app.png" ,
2025-03-28 21:05:23 +00:00
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe89f" ) ,
2016-01-06 21:34:42 +00:00
Action = c = >
2015-11-08 11:21:48 +00:00
{
2025-09-27 16:18:33 +00:00
Context . API . HideMainWindow ( ) ;
2016-05-25 00:00:10 +00:00
Application . Current . MainWindow . Close ( ) ;
2015-11-08 11:21:48 +00:00
return true ;
}
} ,
new Result
2019-08-22 11:37:36 +00:00
{
2024-01-15 15:16:07 +00:00
Title = "Save Settings" ,
2025-03-28 21:05:23 +00:00
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xea35" ) ,
2019-08-22 11:37:36 +00:00
IcoPath = "Images\\app.png" ,
Action = c = >
{
2025-09-27 16:18:33 +00:00
Context . API . SaveAppAllSettings ( ) ;
Context . API . ShowMsg ( Localize . flowlauncher_plugin_sys_dlgtitle_success ( ) ,
Localize . flowlauncher_plugin_sys_dlgtext_all_settings_saved ( ) ) ;
2019-08-22 11:37:36 +00:00
return true ;
}
} ,
new Result
2015-11-08 11:21:48 +00:00
{
2025-03-28 21:05:23 +00:00
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe72c" ) ,
2024-01-15 15:16:07 +00:00
Title = "Restart Flow Launcher" ,
2016-04-25 22:20:16 +00:00
IcoPath = "Images\\app.png" ,
2016-01-06 21:34:42 +00:00
Action = c = >
2015-11-08 11:21:48 +00:00
{
2025-09-27 16:18:33 +00:00
Context . API . RestartApp ( ) ;
2015-11-26 02:04:44 +00:00
return false ;
2015-11-08 11:21:48 +00:00
}
} ,
new Result
{
2024-01-15 15:16:07 +00:00
Title = "Settings" ,
2025-03-28 21:05:23 +00:00
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xf210" ) ,
2015-11-08 11:21:48 +00:00
IcoPath = "Images\\app.png" ,
2016-01-06 21:34:42 +00:00
Action = c = >
2015-11-08 11:21:48 +00:00
{
2025-07-20 01:35:29 +00:00
// Hide the window first then open setting dialog because main window can be topmost window which will still display on top of the setting dialog for a while
2025-09-27 16:18:33 +00:00
Context . API . HideMainWindow ( ) ;
Context . API . OpenSettingDialog ( ) ;
2015-11-08 11:21:48 +00:00
return true ;
}
2019-10-08 11:48:56 +00:00
} ,
2019-10-08 19:24:42 +00:00
new Result
2019-10-08 11:48:56 +00:00
{
2024-01-15 15:16:07 +00:00
Title = "Reload Plugin Data" ,
2019-10-08 11:48:56 +00:00
IcoPath = "Images\\app.png" ,
2025-03-28 21:05:23 +00:00
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe72c" ) ,
2019-10-08 11:48:56 +00:00
Action = c = >
{
2019-10-08 19:18:09 +00:00
// Hide the window first then show msg after done because sometimes the reload could take a while, so not to make user think it's frozen.
2025-09-27 16:18:33 +00:00
Context . API . HideMainWindow ( ) ;
_ = Context . API . ReloadAllPluginData ( ) . ContinueWith ( _ = >
Context . API . ShowMsg (
Localize . flowlauncher_plugin_sys_dlgtitle_success ( ) ,
Localize . flowlauncher_plugin_sys_dlgtext_all_applicableplugins_reloaded ( ) ) ,
TaskScheduler . Current ) ;
2019-10-08 11:48:56 +00:00
return true ;
}
2020-02-25 10:08:51 +00:00
} ,
new Result
{
2024-01-15 15:16:07 +00:00
Title = "Check For Update" ,
2025-03-28 21:05:23 +00:00
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xede4" ) ,
2020-02-25 10:08:51 +00:00
IcoPath = "Images\\checkupdate.png" ,
Action = c = >
{
2025-09-27 16:18:33 +00:00
Context . API . HideMainWindow ( ) ;
Context . API . CheckForNewUpdate ( ) ;
2020-02-25 10:08:51 +00:00
return true ;
}
2021-03-06 05:30:18 +00:00
} ,
new Result
{
2025-03-28 21:05:23 +00:00
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xf12b" ) ,
2024-01-15 15:16:07 +00:00
Title = "Open Log Location" ,
2021-03-06 05:30:18 +00:00
IcoPath = "Images\\app.png" ,
2025-09-27 16:18:33 +00:00
CopyText = Context . API . GetLogDirectory ( ) ,
AutoCompleteText = Context . API . GetLogDirectory ( ) ,
2021-03-06 05:30:18 +00:00
Action = c = >
{
2025-09-27 16:18:33 +00:00
Context . API . OpenDirectory ( Context . API . GetLogDirectory ( ) ) ;
2021-04-18 21:23:50 +00:00
return true ;
}
} ,
new Result
{
2024-01-15 15:16:07 +00:00
Title = "Flow Launcher Tips" ,
2025-03-28 21:05:23 +00:00
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe897" ) ,
2021-04-18 21:23:50 +00:00
IcoPath = "Images\\app.png" ,
2025-07-20 01:58:30 +00:00
CopyText = Documentation ,
AutoCompleteText = Documentation ,
2021-04-18 21:23:50 +00:00
Action = c = >
{
2025-09-27 16:18:33 +00:00
Context . API . OpenUrl ( Documentation ) ;
2021-04-18 21:23:50 +00:00
return true ;
}
} ,
new Result
{
2024-01-15 15:16:07 +00:00
Title = "Flow Launcher UserData Folder" ,
2025-03-28 21:05:23 +00:00
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xf12b" ) ,
2021-04-18 21:23:50 +00:00
IcoPath = "Images\\app.png" ,
2025-09-27 16:18:33 +00:00
CopyText = Context . API . GetDataDirectory ( ) ,
AutoCompleteText = Context . API . GetDataDirectory ( ) ,
2021-04-18 21:23:50 +00:00
Action = c = >
{
2025-09-27 16:18:33 +00:00
Context . API . OpenDirectory ( Context . API . GetDataDirectory ( ) ) ;
2021-03-06 05:30:18 +00:00
return true ;
}
2024-01-14 13:31:21 +00:00
} ,
new Result
{
Title = "Toggle Game Mode" ,
IcoPath = "Images\\app.png" ,
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\ue7fc" ) ,
Action = c = >
{
2025-09-27 16:18:33 +00:00
Context . API . ToggleGameMode ( ) ;
2024-01-14 13:31:21 +00:00
return true ;
}
2024-06-15 11:16:36 +00:00
} ,
new Result
{
Title = "Set Flow Launcher Theme" ,
2025-03-12 10:54:43 +00:00
IcoPath = "Images\\app.png" ,
2025-03-28 21:05:23 +00:00
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\ue790" ) ,
2024-06-15 11:16:36 +00:00
Action = c = >
{
2025-07-15 13:59:40 +00:00
if ( string . IsNullOrEmpty ( query . ActionKeyword ) )
{
2025-09-27 16:18:33 +00:00
Context . API . ChangeQuery ( $"{ThemeSelector.Keyword}{Plugin.Query.ActionKeywordSeparator}" ) ;
2025-07-15 13:59:40 +00:00
}
else
{
2025-09-27 16:18:33 +00:00
Context . API . ChangeQuery ( $"{query.ActionKeyword}{Plugin.Query.ActionKeywordSeparator}{ThemeSelector.Keyword}{Plugin.Query.ActionKeywordSeparator}" ) ;
2025-07-15 13:59:40 +00:00
}
2024-06-15 11:16:36 +00:00
return false ;
}
2015-11-08 11:21:48 +00:00
}
2025-09-27 16:18:33 +00:00
] ) ;
2021-04-18 21:29:58 +00:00
2017-02-21 02:19:50 +00:00
return results ;
2014-07-25 00:32:19 +00:00
}
2015-02-07 12:17:49 +00:00
public string GetTranslatedPluginTitle ( )
{
2025-09-27 16:18:33 +00:00
return Localize . flowlauncher_plugin_sys_plugin_name ( ) ;
2015-02-07 12:17:49 +00:00
}
public string GetTranslatedPluginDescription ( )
{
2025-09-27 16:18:33 +00:00
return Localize . flowlauncher_plugin_sys_plugin_description ( ) ;
2025-03-13 15:29:00 +00:00
}
public void OnCultureInfoChanged ( CultureInfo _ )
{
UpdateLocalizedNameDescription ( true ) ;
2015-02-07 12:17:49 +00:00
}
2015-02-27 10:04:49 +00:00
}
2022-08-08 04:31:38 +00:00
}