mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-19 15:51:45 +00:00
49 lines
1.1 KiB
C#
49 lines
1.1 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
|
|
namespace BepInEx.Unity.IL2CPP.Utils;
|
|
|
|
internal static class NotifySend
|
|
{
|
|
private const string EXECUTABLE_NAME = "notify-send";
|
|
|
|
public static bool IsSupported => Find(EXECUTABLE_NAME) != null;
|
|
|
|
private static string Find(string fileName)
|
|
{
|
|
if (File.Exists(fileName))
|
|
return Path.GetFullPath(fileName);
|
|
|
|
var paths = Environment.GetEnvironmentVariable("PATH");
|
|
if (paths == null)
|
|
return null;
|
|
|
|
foreach (var path in paths.Split(Path.PathSeparator))
|
|
{
|
|
var fullPath = Path.Combine(path, fileName);
|
|
if (File.Exists(fullPath))
|
|
return fullPath;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public static void Send(string summary, string body)
|
|
{
|
|
if (!IsSupported) throw new NotSupportedException();
|
|
|
|
var processStartInfo = new ProcessStartInfo(Find(EXECUTABLE_NAME))
|
|
{
|
|
ArgumentList =
|
|
{
|
|
summary,
|
|
body,
|
|
"--app-name=BepInEx",
|
|
},
|
|
};
|
|
|
|
Process.Start(processStartInfo);
|
|
}
|
|
}
|