dashboard.ts: add local notify-send popups (desktop notifications) alongside NTFY/Apprise
This commit is contained in:
@@ -211,6 +211,19 @@ export default function (pi: ExtensionAPI) {
|
||||
}
|
||||
|
||||
function notify(title: string, body: string) {
|
||||
// Desktop notification (local machine popup)
|
||||
try {
|
||||
const child = spawn(
|
||||
"notify-send",
|
||||
["-a", "Pi Dashboard", title, body],
|
||||
{ stdio: "ignore", timeout: 3000 }
|
||||
);
|
||||
child.on("error", () => {});
|
||||
child.unref();
|
||||
} catch {
|
||||
// notify-send unavailable (e.g. headless server)
|
||||
}
|
||||
|
||||
// NTFY notification
|
||||
const ntfyTopic = process.env.PI_NTFY_TOPIC;
|
||||
if (ntfyTopic) {
|
||||
@@ -236,16 +249,31 @@ export default function (pi: ExtensionAPI) {
|
||||
}
|
||||
}
|
||||
|
||||
// Apprise notification
|
||||
// Apprise notification (HTTP API on .35 — fans out to Telegram/ntfy/email/callmebot)
|
||||
const appriseApi =
|
||||
process.env.APPRISE_API_URL ||
|
||||
"http://192.168.20.35:8210/notify/eaef201fc995964c8a4013892563ae79879df4ecddbabdc4f4af1e549d3366e1";
|
||||
try {
|
||||
const child = spawn("apprise", ["-b", `${title}: ${body}`], {
|
||||
stdio: "ignore",
|
||||
timeout: 3000,
|
||||
});
|
||||
const child = spawn(
|
||||
"curl",
|
||||
[
|
||||
"-s",
|
||||
"-o",
|
||||
"/dev/null",
|
||||
"-X",
|
||||
"POST",
|
||||
"-H",
|
||||
"Content-Type: application/json",
|
||||
"-d",
|
||||
JSON.stringify({ title, body }),
|
||||
appriseApi,
|
||||
],
|
||||
{ stdio: "ignore", timeout: 5000 }
|
||||
);
|
||||
child.on("error", () => {});
|
||||
child.unref();
|
||||
} catch {
|
||||
// Apprise not installed
|
||||
// Apprise unavailable
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user