Add the macOS inhibitor task
ADD
WalletWasabi/Helpers/PowerSaving/MacOsInhibitorTask.cs
+using System.Diagnostics;
+using WalletWasabi.Logging;
+using WalletWasabi.Microservices;
+
+namespace WalletWasabi.Helpers.PowerSaving;
+
+/// <summary>
+/// Inhibitor based on <c>caffeinate</c> command.
+/// </summary>
+public class MacOsInhibitorTask : BaseInhibitorTask
+{
+ /// <remarks>Use the constructor only in tests.</remarks>
+ internal MacOsInhibitorTask(TimeSpan period, string reason, ProcessAsync process)
+ : base(period, reason, process)
+ {
+ }
+
+ public static MacOsInhibitorTask Create(TimeSpan basePeriod, string reason)
+ {
+ // TODO: Make sure that the caffeinate is terminated once the parent process (WW) finishes.
+ string command = $"caffeinate";
+ string arguments = $"-i";
+
+ Logger.LogTrace($"Command to invoke: {command} {arguments}");
+ ProcessStartInfo startInfo = GetProcessStartInfo(command, arguments);
+
+ ProcessAsync process = new(startInfo);
+ process.Start();
+ MacOsInhibitorTask task = new(basePeriod, reason, process);
+
+ return task;
+ }
+}

Add the macOS inhibitor task