feat: introduce a background daemon service for persistent operation and inter-process communication.
This commit is contained in:
@@ -4,8 +4,12 @@ namespace Toak.IO;
|
||||
|
||||
public static class Notifications
|
||||
{
|
||||
private static bool _notifySendAvailable = true;
|
||||
|
||||
public static void Notify(string summary, string body = "")
|
||||
{
|
||||
if (!_notifySendAvailable) return;
|
||||
|
||||
try
|
||||
{
|
||||
var pInfo = new ProcessStartInfo
|
||||
@@ -17,15 +21,22 @@ public static class Notifications
|
||||
};
|
||||
Process.Start(pInfo);
|
||||
}
|
||||
catch (System.ComponentModel.Win32Exception)
|
||||
{
|
||||
Console.WriteLine("[Notifications] 'notify-send' executable not found. Notifications will be disabled.");
|
||||
_notifySendAvailable = false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"[Notifications] Failed to send notification: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private static bool _paplayAvailable = true;
|
||||
|
||||
public static void PlaySound(string soundPath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(soundPath)) return;
|
||||
if (!_paplayAvailable || string.IsNullOrWhiteSpace(soundPath)) return;
|
||||
try
|
||||
{
|
||||
var absolutePath = soundPath;
|
||||
@@ -60,6 +71,11 @@ public static class Notifications
|
||||
};
|
||||
Process.Start(pInfo);
|
||||
}
|
||||
catch (System.ComponentModel.Win32Exception)
|
||||
{
|
||||
Console.WriteLine("[Notifications] 'paplay' executable not found. Sound effects will be disabled.");
|
||||
_paplayAvailable = false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"[Notifications] Failed to play sound: {ex.Message}");
|
||||
|
||||
Reference in New Issue
Block a user