From 114631da4d2cc13d44caf8ea41a29745c9bf167d Mon Sep 17 00:00:00 2001 From: Ralf Vogler Date: Thu, 23 Feb 2023 23:34:27 +0100 Subject: [PATCH] add NOTIFY_TITLE - Optional title for notifications, e.g. Pushover, #69 --- README.md | 1 + config.js | 1 + util.js | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5f88f56..9b101cb 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ Available options/variables and their default values: | HEIGHT | 1280 | Height of the opened browser (and of screen for VNC in Docker). | | VNC_PASSWORD | | VNC password for Docker. No password used by default! | | NOTIFY | | Notification services to use (Pushover, Slack, Telegram...), see below. | +| NOTIFY_TITLE | | Optional title for notifications, e.g. for Pushover. | | BROWSER_DIR | data/browser | Directory for browser profile, e.g. for multiple accounts. | | TIMEOUT | 60 | Timeout for any page action. Should be fine even on slow machines. | | LOGIN_TIMEOUT | 180 | Timeout for login in seconds. Will wait twice (prompt + manual login). | diff --git a/config.js b/config.js index 6ae802f..e9cf1c1 100644 --- a/config.js +++ b/config.js @@ -15,6 +15,7 @@ export const cfg = { login_timeout: (Number(process.env.LOGIN_TIMEOUT) || 180) * 1000, // higher timeout for login, will wait twice: prompt + wait for manual login novnc_port: process.env.NOVNC_PORT, // running in docker if set notify: process.env.NOTIFY, // apprise notification services + notify_title: process.env.NOTIFY_TITLE, // apprise notification title get dir() { // avoids ReferenceError: Cannot access 'dataDir' before initialization return { browser: process.env.BROWSER_DIR || dataDir('browser'), // for multiple accounts or testing diff --git a/util.js b/util.js index 1666a58..a1d6d40 100644 --- a/util.js +++ b/util.js @@ -101,7 +101,8 @@ import { cfg } from './config.js'; export const notify = (html) => { if (!cfg.notify) return; - exec(`apprise ${cfg.notify} -i html -b '${html}'`, (error, stdout, stderr) => { + const title = cfg.notify_title ? `-t ${cfg.notify_title}` : ''; + exec(`apprise ${cfg.notify} -i html ${title} -b '${html}'`, (error, stdout, stderr) => { if (error) { console.log(`error: ${error.message}`); if (error.message.includes('command not found')) {