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 ;
2021-03-06 05:30:18 +00:00
using System.IO ;
2025-02-17 16:08:15 +00:00
using System.Runtime.InteropServices ;
2015-11-26 01:27:18 +00:00
using System.Windows ;
2020-04-21 09:12:17 +00:00
using Flow.Launcher.Infrastructure ;
2024-01-15 15:16:07 +00:00
using Flow.Launcher.Infrastructure.Logger ;
2021-03-06 05:30:18 +00:00
using Flow.Launcher.Infrastructure.UserSettings ;
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
{
2015-01-07 14:23:10 +00:00
private PluginInitContext context ;
2024-06-15 11:16:36 +00:00
private ThemeSelector themeSelector ;
2024-01-15 15:16:07 +00:00
private Dictionary < string , string > KeywordTitleMappings = new Dictionary < string , string > ( ) ;
2014-07-25 00:32:19 +00:00
2025-02-18 03:07:18 +00:00
// SHTDN_REASON_MAJOR_OTHER indicates a generic shutdown reason that isn't categorized under hardware failure, software updates, or other predefined reasons.
// SHTDN_REASON_FLAG_PLANNED marks the shutdown as planned rather than an unexpected shutdown or failure
private const SHUTDOWN_REASON REASON = SHUTDOWN_REASON . SHTDN_REASON_MAJOR_OTHER | SHUTDOWN_REASON . SHTDN_REASON_FLAG_PLANNED ;
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
{
2017-02-21 02:19:50 +00:00
var results = Commands ( ) ;
return new SysSettings ( results ) ;
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
{
2024-06-15 11:16:36 +00:00
if ( query . Search . StartsWith ( ThemeSelector . Keyword ) )
{
return themeSelector . Query ( query ) ;
}
2017-02-21 02:19:50 +00:00
var commands = Commands ( ) ;
var results = new List < Result > ( ) ;
foreach ( var c in commands )
2014-07-25 00:32:19 +00:00
{
2024-01-15 15:16:07 +00:00
c . Title = GetDynamicTitle ( query , c ) ;
2019-12-03 14:25:19 +00:00
var titleMatch = StringMatcher . FuzzySearch ( query . Search , c . Title ) ;
var subTitleMatch = StringMatcher . FuzzySearch ( query . Search , c . SubTitle ) ;
var score = Math . Max ( titleMatch . Score , subTitleMatch . Score ) ;
2016-04-23 23:37:25 +00:00
if ( score > 0 )
2014-07-25 00:32:19 +00:00
{
2017-02-21 02:19:50 +00:00
c . Score = score ;
2021-12-20 20:19:31 +00:00
2019-12-03 14:25:19 +00:00
if ( score = = titleMatch . Score )
c . TitleHighlightData = titleMatch . MatchData ;
2021-01-02 07:52:41 +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 ;
}
2024-01-15 15:16:07 +00:00
private string GetDynamicTitle ( Query query , Result result )
{
2024-01-18 07:53:48 +00:00
if ( ! KeywordTitleMappings . TryGetValue ( result . Title , out var translationKey ) )
2024-01-15 15:16:07 +00:00
{
2024-01-21 14:30:23 +00:00
Log . Error ( "Flow.Launcher.Plugin.Sys.Main" , $"Dynamic Title not found for: {result.Title}" ) ;
2024-01-15 15:16:07 +00:00
return "Title Not Found" ;
}
2024-01-18 07:53:48 +00:00
var translatedTitle = context . API . GetTranslation ( translationKey ) ;
if ( result . Title = = translatedTitle )
{
return result . Title ;
}
var englishTitleMatch = StringMatcher . FuzzySearch ( query . Search , result . Title ) ;
2024-01-16 20:03:57 +00:00
var translatedTitleMatch = StringMatcher . FuzzySearch ( query . Search , translatedTitle ) ;
2024-01-15 15:16:07 +00:00
2024-01-18 07:53:48 +00:00
return englishTitleMatch . Score > = translatedTitleMatch . Score ? result . Title : translatedTitle ;
2024-01-15 15:16:07 +00:00
}
2015-01-03 07:20:34 +00:00
public void Init ( PluginInitContext context )
2014-07-25 00:32:19 +00:00
{
2015-01-07 14:23:10 +00:00
this . context = context ;
2024-06-15 11:16:36 +00:00
themeSelector = new ThemeSelector ( context ) ;
2024-01-15 15:16:07 +00:00
KeywordTitleMappings = new Dictionary < string , string > {
2024-01-16 20:03:57 +00:00
{ "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" } ,
2024-01-16 20:04:47 +00:00
{ "Flow Launcher UserData Folder" , "flowlauncher_plugin_sys_open_userdata_location_cmd" } ,
2024-06-15 11:16:36 +00:00
{ "Toggle Game Mode" , "flowlauncher_plugin_sys_toggle_game_mode_cmd" } ,
{ "Set Flow Launcher Theme" , "flowlauncher_plugin_sys_theme_selector_cmd" }
2024-01-15 15:16:07 +00:00
} ;
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 } }
} ;
if ( ! PInvoke . AdjustTokenPrivileges ( tokenHandle , false , & privileges , 0 , null , null ) )
{
return false ;
}
if ( Marshal . GetLastWin32Error ( ) ! = ( int ) WIN32_ERROR . NO_ERROR )
{
return false ;
}
return true ;
}
catch ( Exception )
{
return false ;
}
}
2017-02-21 02:19:50 +00:00
private List < Result > Commands ( )
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:38:28 +00:00
var logPath = Path . Combine ( DataLocation . DataDirectory ( ) , "Logs" , Constant . Version ) ;
2024-12-07 22:45:32 +00:00
var userDataPath = DataLocation . DataDirectory ( ) ;
var recycleBinFolder = "shell:RecycleBinFolder" ;
2017-02-21 02:19:50 +00:00
results . AddRange ( new [ ]
2015-11-26 01:27:18 +00:00
{
2015-11-08 11:21:48 +00:00
new Result
{
2024-01-15 15:16:07 +00:00
Title = "Shutdown" ,
2020-04-21 12:54:41 +00:00
SubTitle = context . API . GetTranslation ( "flowlauncher_plugin_sys_shutdown_computer" ) ,
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
{
2024-11-27 04:21:34 +00:00
var result = context . API . ShowMsgBox (
2021-01-02 07:52:41 +00:00
context . API . GetTranslation ( "flowlauncher_plugin_sys_dlgtext_shutdown_computer" ) ,
context . API . GetTranslation ( "flowlauncher_plugin_sys_shutdown_computer" ) ,
MessageBoxButton . YesNo , MessageBoxImage . Warning ) ;
2025-02-17 15:12:46 +00:00
2022-12-31 15:43:07 +00:00
if ( result = = MessageBoxResult . Yes )
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" ) ;
2021-01-02 07:52:41 +00:00
2015-11-08 11:21:48 +00:00
return true ;
}
} ,
new Result
2015-11-25 17:49:44 +00:00
{
2024-01-15 15:16:07 +00:00
Title = "Restart" ,
2020-04-21 12:54:41 +00:00
SubTitle = context . API . GetTranslation ( "flowlauncher_plugin_sys_restart_computer" ) ,
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
{
2024-11-27 04:21:34 +00:00
var result = context . API . ShowMsgBox (
2021-01-02 07:52:41 +00:00
context . API . GetTranslation ( "flowlauncher_plugin_sys_dlgtext_restart_computer" ) ,
context . API . GetTranslation ( "flowlauncher_plugin_sys_restart_computer" ) ,
MessageBoxButton . YesNo , MessageBoxImage . Warning ) ;
2025-02-17 15:12:46 +00:00
2015-11-26 01:27:18 +00:00
if ( result = = MessageBoxResult . Yes )
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 , REASON ) ;
2025-02-17 16:08:15 +00:00
else
Process . Start ( "shutdown" , "/r /t 0" ) ;
2021-01-02 07:52:41 +00:00
2015-11-25 17:49:44 +00:00
return true ;
}
} ,
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-09-05 23:02:04 +00:00
SubTitle = context . API . GetTranslation ( "flowlauncher_plugin_sys_restart_advanced" ) ,
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 = >
{
2024-11-27 04:21:34 +00:00
var result = context . API . ShowMsgBox (
2021-09-05 23:02:04 +00:00
context . API . GetTranslation ( "flowlauncher_plugin_sys_dlgtext_restart_computer_advanced" ) ,
context . API . GetTranslation ( "flowlauncher_plugin_sys_restart_computer" ) ,
MessageBoxButton . YesNo , MessageBoxImage . Warning ) ;
2024-01-15 15:16:07 +00:00
2021-09-05 23:02:04 +00:00
if ( result = = MessageBoxResult . Yes )
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" ) ;
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" ,
2020-04-21 12:54:41 +00:00
SubTitle = context . API . GetTranslation ( "flowlauncher_plugin_sys_log_off" ) ,
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 = >
{
2024-11-27 04:21:34 +00:00
var result = context . API . ShowMsgBox (
2022-12-31 03:54:55 +00:00
context . API . GetTranslation ( "flowlauncher_plugin_sys_dlgtext_logoff_computer" ) ,
context . API . GetTranslation ( "flowlauncher_plugin_sys_log_off" ) ,
MessageBoxButton . YesNo , MessageBoxImage . Warning ) ;
2024-01-15 15:16:07 +00:00
2022-12-31 03:54:55 +00:00
if ( result = = MessageBoxResult . Yes )
2025-02-18 03:07:18 +00:00
PInvoke . ExitWindowsEx ( EXIT_WINDOWS_FLAGS . EWX_LOGOFF , REASON ) ;
2022-12-31 03:54:55 +00:00
return true ;
}
2015-11-08 11:21:48 +00:00
} ,
new Result
{
2024-01-15 15:16:07 +00:00
Title = "Lock" ,
2020-04-21 12:54:41 +00:00
SubTitle = context . API . GetTranslation ( "flowlauncher_plugin_sys_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" ,
2020-04-21 12:54:41 +00:00
SubTitle = context . API . GetTranslation ( "flowlauncher_plugin_sys_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" ,
2020-04-21 12:54:41 +00:00
SubTitle = context . API . GetTranslation ( "flowlauncher_plugin_sys_hibernate" ) ,
2021-10-07 10:58:54 +00:00
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe945" ) ,
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
SubTitle = context . API . GetTranslation ( "flowlauncher_plugin_sys_indexoption" ) ,
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" ,
2020-04-21 12:54:41 +00:00
SubTitle = context . API . GetTranslation ( "flowlauncher_plugin_sys_emptyrecyclebin" ) ,
2021-10-07 10:58:54 +00:00
IcoPath = "Images\\recyclebin.png" ,
2022-09-13 00:11:17 +00:00
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe74d" ) ,
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
{
2024-12-20 10:55:57 +00:00
context . API . ShowMsgBox ( "Failed to empty the recycle bin. This might happen if:\n" +
"- A file in the recycle bin is in use\n" +
"- You don't have permission to delete some items\n" +
"Please close any applications that might be using these files and try again." ,
2021-01-02 07:52:41 +00:00
"Error" ,
MessageBoxButton . OK , MessageBoxImage . Error ) ;
2015-11-25 17:49:44 +00:00
}
2021-01-02 07:52:41 +00:00
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 08:43:25 +00:00
SubTitle = context . API . GetTranslation ( "flowlauncher_plugin_sys_openrecyclebin" ) ,
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" ,
2020-04-21 12:54:41 +00:00
SubTitle = context . API . GetTranslation ( "flowlauncher_plugin_sys_exit" ) ,
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
{
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" ,
2020-04-21 12:54:41 +00:00
SubTitle = context . API . GetTranslation ( "flowlauncher_plugin_sys_save_all_settings" ) ,
2019-08-22 11:37:36 +00:00
IcoPath = "Images\\app.png" ,
Action = c = >
{
context . API . SaveAppAllSettings ( ) ;
2020-04-21 12:54:41 +00:00
context . API . ShowMsg ( context . API . GetTranslation ( "flowlauncher_plugin_sys_dlgtitle_success" ) ,
context . API . GetTranslation ( "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
{
2024-01-15 15:16:07 +00:00
Title = "Restart Flow Launcher" ,
2020-04-21 12:54:41 +00:00
SubTitle = context . API . GetTranslation ( "flowlauncher_plugin_sys_restart" ) ,
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
{
2020-04-30 06:54:13 +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" ,
2020-04-21 12:54:41 +00:00
SubTitle = context . API . GetTranslation ( "flowlauncher_plugin_sys_setting" ) ,
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
{
context . API . OpenSettingDialog ( ) ;
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" ,
2020-04-21 12:54:41 +00:00
SubTitle = context . API . GetTranslation ( "flowlauncher_plugin_sys_reload_plugin_data" ) ,
2019-10-08 11:48:56 +00:00
IcoPath = "Images\\app.png" ,
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-02-18 03:41:26 +00:00
context . API . HideMainWindow ( ) ;
2021-01-02 07:52:41 +00:00
2022-08-09 00:35:38 +00:00
_ = context . API . ReloadAllPluginData ( ) . ContinueWith ( _ = >
2021-01-02 07:52:41 +00:00
context . API . ShowMsg (
context . API . GetTranslation ( "flowlauncher_plugin_sys_dlgtitle_success" ) ,
context . API . GetTranslation (
2022-08-09 00:35:38 +00:00
"flowlauncher_plugin_sys_dlgtext_all_applicableplugins_reloaded" ) ) ,
System . Threading . Tasks . TaskScheduler . Current ) ;
2024-01-15 15:16:07 +00:00
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" ,
2021-03-30 19:28:25 +00:00
SubTitle = context . API . GetTranslation ( "flowlauncher_plugin_sys_check_for_update" ) ,
2020-02-25 10:08:51 +00:00
IcoPath = "Images\\checkupdate.png" ,
Action = c = >
{
2025-02-18 03:41:26 +00:00
context . API . HideMainWindow ( ) ;
2020-02-25 10:08:51 +00:00
context . API . CheckForNewUpdate ( ) ;
return true ;
}
2021-03-06 05:30:18 +00:00
} ,
new Result
{
2024-01-15 15:16:07 +00:00
Title = "Open Log Location" ,
2021-03-30 19:28:25 +00:00
SubTitle = context . API . GetTranslation ( "flowlauncher_plugin_sys_open_log_location" ) ,
2021-03-06 05:30:18 +00:00
IcoPath = "Images\\app.png" ,
2024-12-07 22:38:28 +00:00
CopyText = logPath ,
2024-12-07 22:45:32 +00:00
AutoCompleteText = logPath ,
2021-03-06 05:30:18 +00:00
Action = c = >
{
2021-11-06 00:23:09 +00:00
context . API . OpenDirectory ( logPath ) ;
2021-04-18 21:23:50 +00:00
return true ;
}
} ,
new Result
{
2024-01-15 15:16:07 +00:00
Title = "Flow Launcher Tips" ,
2021-04-18 21:23:50 +00:00
SubTitle = context . API . GetTranslation ( "flowlauncher_plugin_sys_open_docs_tips" ) ,
IcoPath = "Images\\app.png" ,
2024-12-07 22:38:28 +00:00
CopyText = Constant . Documentation ,
2024-12-07 22:45:32 +00:00
AutoCompleteText = Constant . Documentation ,
2021-04-18 21:23:50 +00:00
Action = c = >
{
2021-12-05 19:34:23 +00:00
context . API . OpenUrl ( Constant . 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" ,
2021-04-18 21:23:50 +00:00
SubTitle = context . API . GetTranslation ( "flowlauncher_plugin_sys_open_userdata_location" ) ,
IcoPath = "Images\\app.png" ,
2024-12-07 22:38:28 +00:00
CopyText = userDataPath ,
2024-12-07 22:45:32 +00:00
AutoCompleteText = userDataPath ,
2021-04-18 21:23:50 +00:00
Action = c = >
{
2024-12-07 22:38:28 +00:00
context . API . OpenDirectory ( userDataPath ) ;
2021-03-06 05:30:18 +00:00
return true ;
}
2024-01-14 13:31:21 +00:00
} ,
new Result
{
Title = "Toggle Game Mode" ,
SubTitle = context . API . GetTranslation ( "flowlauncher_plugin_sys_toggle_game_mode" ) ,
IcoPath = "Images\\app.png" ,
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\ue7fc" ) ,
Action = c = >
{
context . API . ToggleGameMode ( ) ;
return true ;
}
2024-06-15 11:16:36 +00:00
} ,
new Result
{
Title = "Set Flow Launcher Theme" ,
SubTitle = context . API . GetTranslation ( "flowlauncher_plugin_sys_theme_selector" ) ,
2025-03-12 10:54:43 +00:00
IcoPath = "Images\\app.png" ,
Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\ue7fc" ) ,
2024-06-15 11:16:36 +00:00
Action = c = >
{
context . API . ChangeQuery ( $"{ThemeSelector.Keyword} " ) ;
return false ;
}
2015-11-08 11:21:48 +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 ( )
{
2020-04-21 12:54:41 +00:00
return context . API . GetTranslation ( "flowlauncher_plugin_sys_plugin_name" ) ;
2015-02-07 12:17:49 +00:00
}
public string GetTranslatedPluginDescription ( )
{
2020-04-21 12:54:41 +00:00
return context . API . GetTranslation ( "flowlauncher_plugin_sys_plugin_description" ) ;
2015-02-07 12:17:49 +00:00
}
2015-02-27 10:04:49 +00:00
}
2022-08-08 04:31:38 +00:00
}