Skip to content

Commit 48cbbba

Browse files
committed
Add WindowsServices plugin, based on PowerToys CmdPal's
1 parent 0769b84 commit 48cbbba

File tree

7 files changed

+439
-0
lines changed

7 files changed

+439
-0
lines changed

Flow.Launcher.sln

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher", "Flow.Launc
1010
{588088F4-3262-4F9F-9663-A05DE12534C3} = {588088F4-3262-4F9F-9663-A05DE12534C3}
1111
{59BD9891-3837-438A-958D-ADC7F91F6F7E} = {59BD9891-3837-438A-958D-ADC7F91F6F7E}
1212
{C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0} = {C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0}
13+
{F68C5D49-5338-48CC-AEED-3F0B852B2657} = {F68C5D49-5338-48CC-AEED-3F0B852B2657}
1314
{FDB3555B-58EF-4AE6-B5F1-904719637AB4} = {FDB3555B-58EF-4AE6-B5F1-904719637AB4}
1415
{FDED22C8-B637-42E8-824A-63B5B6E05A3A} = {FDED22C8-B637-42E8-824A-63B5B6E05A3A}
1516
EndProjectSection
@@ -65,6 +66,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flow.LauncherWinUI", "Flow.
6566
EndProject
6667
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Flow.Plugin.RegJump", "Plugins\Flow.Plugin.RegJump\src\Flow.Plugin.RegJump.fsproj", "{037FC1AE-9FAE-E4E0-408B-0CB5F5847A20}"
6768
EndProject
69+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flow.Launcher.Plugin.WindowsServices", "Plugins\Flow.Launcher.Plugin.WindowsServices\Flow.Launcher.Plugin.WindowsServices.csproj", "{F68C5D49-5338-48CC-AEED-3F0B852B2657}"
70+
EndProject
6871
Global
6972
GlobalSection(SolutionConfigurationPlatforms) = preSolution
7073
Debug|Any CPU = Debug|Any CPU
@@ -272,6 +275,18 @@ Global
272275
{037FC1AE-9FAE-E4E0-408B-0CB5F5847A20}.Release|x64.Build.0 = Release|Any CPU
273276
{037FC1AE-9FAE-E4E0-408B-0CB5F5847A20}.Release|x86.ActiveCfg = Release|Any CPU
274277
{037FC1AE-9FAE-E4E0-408B-0CB5F5847A20}.Release|x86.Build.0 = Release|Any CPU
278+
{F68C5D49-5338-48CC-AEED-3F0B852B2657}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
279+
{F68C5D49-5338-48CC-AEED-3F0B852B2657}.Debug|Any CPU.Build.0 = Debug|Any CPU
280+
{F68C5D49-5338-48CC-AEED-3F0B852B2657}.Debug|x64.ActiveCfg = Debug|Any CPU
281+
{F68C5D49-5338-48CC-AEED-3F0B852B2657}.Debug|x64.Build.0 = Debug|Any CPU
282+
{F68C5D49-5338-48CC-AEED-3F0B852B2657}.Debug|x86.ActiveCfg = Debug|Any CPU
283+
{F68C5D49-5338-48CC-AEED-3F0B852B2657}.Debug|x86.Build.0 = Debug|Any CPU
284+
{F68C5D49-5338-48CC-AEED-3F0B852B2657}.Release|Any CPU.ActiveCfg = Release|Any CPU
285+
{F68C5D49-5338-48CC-AEED-3F0B852B2657}.Release|Any CPU.Build.0 = Release|Any CPU
286+
{F68C5D49-5338-48CC-AEED-3F0B852B2657}.Release|x64.ActiveCfg = Release|Any CPU
287+
{F68C5D49-5338-48CC-AEED-3F0B852B2657}.Release|x64.Build.0 = Release|Any CPU
288+
{F68C5D49-5338-48CC-AEED-3F0B852B2657}.Release|x86.ActiveCfg = Release|Any CPU
289+
{F68C5D49-5338-48CC-AEED-3F0B852B2657}.Release|x86.Build.0 = Release|Any CPU
275290
EndGlobalSection
276291
GlobalSection(SolutionProperties) = preSolution
277292
HideSolutionNode = FALSE
@@ -285,6 +300,7 @@ Global
285300
{588088F4-3262-4F9F-9663-A05DE12534C3} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
286301
{5043CECE-E6A7-4867-9CBE-02D27D83747A} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
287302
{037FC1AE-9FAE-E4E0-408B-0CB5F5847A20} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
303+
{F68C5D49-5338-48CC-AEED-3F0B852B2657} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
288304
EndGlobalSection
289305
GlobalSection(ExtensibilityGlobals) = postSolution
290306
SolutionGuid = {F26ACB50-3F6C-4907-B0C9-1ADACC1D0DED}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Library</OutputType>
5+
<TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
6+
<AssemblyName>Flow.Launcher.Plugin.WindowsServices</AssemblyName>
7+
<PackageId>Flow.Launcher.Plugin.WindowsServices</PackageId>
8+
<PackageProjectUrl>https://github.com/TBM13/Flow.Launcher/tree/TBM13/Plugins/Flow.Launcher.Plugin.WindowsServices</PackageProjectUrl>
9+
<RepositoryUrl>https://github.com/TBM13/Flow.Launcher/tree/TBM13/Plugins/Flow.Launcher.Plugin.WindowsServices</RepositoryUrl>
10+
<Authors>TBM13</Authors>
11+
<PackageTags>flow-launcher flow-plugin</PackageTags>
12+
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
13+
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
14+
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
15+
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
16+
<UseWPF>true</UseWPF>
17+
</PropertyGroup>
18+
19+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
20+
<DebugSymbols>true</DebugSymbols>
21+
<DebugType>portable</DebugType>
22+
<Optimize>false</Optimize>
23+
<OutputPath>..\..\Output\Debug\Plugins\Flow.Launcher.Plugin.WindowsServices\</OutputPath>
24+
<DefineConstants>DEBUG;TRACE</DefineConstants>
25+
<ErrorReport>prompt</ErrorReport>
26+
<WarningLevel>4</WarningLevel>
27+
<Prefer32Bit>false</Prefer32Bit>
28+
</PropertyGroup>
29+
30+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
31+
<DebugType>pdbonly</DebugType>
32+
<Optimize>true</Optimize>
33+
<OutputPath>..\..\Output\Release\Plugins\Flow.Launcher.Plugin.WindowsServices\</OutputPath>
34+
<DefineConstants>TRACE</DefineConstants>
35+
<ErrorReport>prompt</ErrorReport>
36+
<WarningLevel>4</WarningLevel>
37+
<Prefer32Bit>false</Prefer32Bit>
38+
</PropertyGroup>
39+
40+
<ItemGroup>
41+
<Content Include="Images\*.png">
42+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
43+
</Content>
44+
<Content Include="plugin.json">
45+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
46+
</Content>
47+
</ItemGroup>
48+
49+
<ItemGroup>
50+
<PackageReference Include="System.ServiceProcess.ServiceController" Version="9.0.7" />
51+
</ItemGroup>
52+
53+
<ItemGroup>
54+
<ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
55+
</ItemGroup>
56+
57+
</Project>
3.97 KB
Loading
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+

2+
using System;
3+
using System.Collections.Generic;
4+
5+
namespace Flow.Launcher.Plugin.WindowsServices;
6+
7+
public class Main : IPlugin, IContextMenu
8+
{
9+
private static PluginInitContext _context;
10+
11+
public void Init(PluginInitContext context)
12+
{
13+
_context = context;
14+
}
15+
16+
public List<Result> Query(Query query)
17+
{
18+
return [.. ServiceHelper.Search(query.Search)];
19+
}
20+
21+
public List<Result> LoadContextMenus(Result result)
22+
{
23+
var service = (ServiceResult)result.ContextData;
24+
25+
if (service.StartMode == System.ServiceProcess.ServiceStartMode.Disabled)
26+
{
27+
return
28+
[
29+
new Result()
30+
{
31+
Title = "Service is disabled",
32+
SubTitle = "Enable it to use start/restart/stop actions.",
33+
Glyph = new(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\xeb90"),
34+
}
35+
];
36+
}
37+
38+
if (!service.IsRunning)
39+
{
40+
return
41+
[
42+
new Result()
43+
{
44+
Title = "Start",
45+
Glyph = new(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\xe768"),
46+
Action = (c) => {
47+
try {
48+
ServiceHelper.ChangeStatus(service, Action.Start);
49+
return true;
50+
}
51+
catch (Exception e) {
52+
_context.API.ShowMsgError("Failed to start service", e.ToString());
53+
return false;
54+
}
55+
}
56+
}
57+
];
58+
}
59+
60+
return
61+
[
62+
new Result()
63+
{
64+
Title = "Restart",
65+
Glyph = new(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\xe777"),
66+
Action = (c) => {
67+
try {
68+
ServiceHelper.ChangeStatus(service, Action.Restart);
69+
return true;
70+
}
71+
catch (Exception e) {
72+
_context.API.ShowMsgError("Failed to restart service", e.ToString());
73+
return false;
74+
}
75+
}
76+
},
77+
78+
new Result()
79+
{
80+
Title = "Stop",
81+
Glyph = new(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\xe769"),
82+
Action = (c) => {
83+
try {
84+
ServiceHelper.ChangeStatus(service, Action.Stop);
85+
return true;
86+
}
87+
catch (Exception e) {
88+
_context.API.ShowMsgError("Failed to stop service", e.ToString());
89+
return false;
90+
}
91+
}
92+
}
93+
];
94+
}
95+
}
96+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<a target="_blank" href="https://icons8.com/icon/GtKvA4suLFWD/services">Services</a> icon by <a target="_blank" href="https://icons8.com">Icons8</a>

0 commit comments

Comments
 (0)