using System.Diagnostics; namespace Toak.IO; public static class Notifications { public static void Notify(string summary, string body = "") { try { var pInfo = new ProcessStartInfo { FileName = "notify-send", Arguments = $"-a \"Toak\" \"{summary}\" \"{body}\"", UseShellExecute = false, CreateNoWindow = true }; Process.Start(pInfo); } catch (Exception ex) { Console.WriteLine($"[Notifications] Failed to send notification: {ex.Message}"); } } public static void PlaySound(string soundPath) { if (string.IsNullOrWhiteSpace(soundPath)) return; try { var absolutePath = soundPath; if (!Path.IsPathRooted(absolutePath)) absolutePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, absolutePath); if (!File.Exists(absolutePath)) { var resourceName = "Toak." + soundPath.Replace("/", ".").Replace("\\", "."); using var stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName); if (stream != null) { absolutePath = Path.Combine(Path.GetTempPath(), "toak_" + Path.GetFileName(soundPath)); if (!File.Exists(absolutePath)) { using var fileStream = File.Create(absolutePath); stream.CopyTo(fileStream); } } else { return; } } var pInfo = new ProcessStartInfo { FileName = "paplay", Arguments = $"\"{absolutePath}\"", UseShellExecute = false, CreateNoWindow = true }; Process.Start(pInfo); } catch (Exception ex) { Console.WriteLine($"[Notifications] Failed to play sound: {ex.Message}"); } } }