Skip to content

Commit

Permalink
Add support for opening and emptying recycle bin (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkgv authored Apr 10, 2024
1 parent ab19749 commit 1bb6ce8
Showing 1 changed file with 39 additions and 1 deletion.
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

0 comments on commit 1bb6ce8

Please sign in to comment.