Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for opening and emptying recycle bin #232

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Changes from all 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
40 changes: 39 additions & 1 deletion Pinpoint.Plugin.OperatingSystem/OperatingSystemPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Pinpoint.Plugin.OperatingSystem
public class OperatingSystemPlugin : AbstractPlugin
{
private static readonly string[] Commands = {
"shutdown", "shut down", "restart", "reboot", "sleep"
"shutdown", "shut down", "restart", "reboot", "sleep", "emptytrash", "emptybin", "trash", "bin"
};

public override PluginManifest Manifest { get; } = new("Operating System", PluginPriority.High)
Expand Down Expand Up @@ -42,7 +42,45 @@ public override async IAsyncEnumerable<AbstractQueryResult> ProcessQuery(Query q
case "sleep":
yield return new SleepResult();
break;

case "emptytrash":
case "emptybin":
yield return new EmptyTrashResult();
break;

case "trash":
case "bin":
yield return new RecycleBin();
break;
}
}

private class RecycleBin : AbstractFontAwesomeQueryResult
{
public RecycleBin() : base("Open recycle bin")
{
}

public override void OnSelect()
{
System.Diagnostics.Process.Start("explorer.exe", "shell:RecycleBinFolder");
}

public override EFontAwesomeIcon FontAwesomeIcon { get; } = EFontAwesomeIcon.Solid_TrashAlt;
}

private class EmptyTrashResult : AbstractFontAwesomeQueryResult
{
public EmptyTrashResult() : base("Empty recycle bin")
{
}

public override void OnSelect()
{
System.Diagnostics.Process.Start("cmd.exe", "/c rd /s /q C:\\$Recycle.Bin");
}

public override EFontAwesomeIcon FontAwesomeIcon { get; } = EFontAwesomeIcon.Solid_TrashAlt;
}

private class ShutdownResult : AbstractFontAwesomeQueryResult
Expand Down