diff --git a/lib/utils.js b/lib/utils.js
index 740f85c..e8ab953 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -28,6 +28,10 @@ const inArray = function (arr, val) {
return arr.indexOf(val) !== -1;
};
+/*
+ notifySend Flags
+*/
+
const notifySendFlags = {
u: 'urgency',
urgency: 'urgency',
@@ -81,6 +85,7 @@ module.exports.fileCommandJson = function (notifier, options, cb) {
console.info('[notifier path]', notifier);
console.info('[notifier options]', options.join(' '));
}
+
return cp.execFile(notifier, options, function (error, stdout, stderr) {
if (error) return cb(error, stdout);
if (!stdout) return cb(error, {});
@@ -161,9 +166,11 @@ module.exports.mapToNotifySend = function (options) {
if (options.timeout === false) {
delete options.timeout;
}
+
if (options.wait === true) {
options['expire-time'] = 5; // 5 seconds default time (multipled below)
}
+
for (const key in options) {
if (key === 'message' || key === 'title') continue;
if (options.hasOwnProperty(key) && notifySendFlags[key] !== key) {
@@ -171,6 +178,7 @@ module.exports.mapToNotifySend = function (options) {
delete options[key];
}
}
+
if (typeof options['expire-time'] === 'undefined') {
options['expire-time'] = 10 * 1000; // 10 sec timeout by default
} else if (typeof options['expire-time'] === 'number') {
@@ -215,10 +223,19 @@ module.exports.mapToMac = function (options) {
options.sound = 'Bottle';
}
+ /*
+ wait : Wait with callback, until user action is taken against notification,
+ does not apply to Windows Toasters as they always wait or notify-send
+ as it does not support the wait option
+
+ timeout : Takes precedence over wait if both are defined.
+ */
+
if (options.wait === true) {
if (!options.timeout) {
options.timeout = 5;
}
+
delete options.wait;
}
@@ -325,20 +342,31 @@ function removeNewLines(str) {
}
/*
----- Options ----
-[-t]
| Displayed on the first line of the toast.
-[-m] | Displayed on the remaining lines, wrapped.
-[-b] | Displayed on the bottom line, can list multiple buttons separated by ";"
-[-tb] | Displayed a textbox on the bottom line, only if buttons are not presented.
-[-p] | Display toast with an image, local files only.
-[-id] | sets the id for a notification to be able to close it later.
-[-s] | Sets the sound of the notifications, for possible values see http://msdn.microsoft.com/en-us/library/windows/apps/hh761492.aspx.
-[-silent] | Don't play a sound file when showing the notifications.
-[-appID] | Don't create a shortcut but use the provided app id.
-[-pid] | Query the appid for the process , use -appID as fallback. (Only relevant for applications that might be packaged for the store)
-[-pipeName] <\.\pipe\pipeName\> | Provide a name pipe which is used for callbacks.
-[-application] | Provide a application that might be started if the pipe does not exist.
--close | Closes a currently displayed notification.
+ Ntfy Toast / Toaster
+
+ Windows 10 & 11 use ntfy-toast library to send notifications:
+ https://github.com/Aetherinox/ntfy-toast
+
+ ntfy-toast has a special parameter for ensuring that notifications stick and do dismiss
+ unless the user physically dismisses them by using:
+ -persistent
+
+ ---- Options ----
+ [-t] | Displayed on the first line of the toast.
+ [-m] | Displayed on the remaining lines, wrapped.
+ [-b] | Displayed on the bottom line, can list multiple buttons separated by ";"
+ [-tb] | Displayed a textbox on the bottom line, only if buttons are not presented.
+ [-p] | Display toast with an image, local files only.
+ [-id] | sets the id for a notification to be able to close it later.
+ [-s] | Sets the sound of the notifications, for possible values see http://msdn.microsoft.com/en-us/library/windows/apps/hh761492.aspx.
+ [-silent] | Don't play a sound file when showing the notifications.
+ [-persistent] | Makes the notification stick until the user dismisses it.
+ [-d] (short | long) | Set the duration default is "short" 7s, "long" is 25s.
+ [-appID] | Don't create a shortcut but use the provided app id.
+ [-pid] | Query the appid for the process , use -appID as fallback. (Only relevant for applications that might be packaged for the store)
+ [-pipeName] <\.\pipe\pipeName\> | Provide a name pipe which is used for callbacks.
+ [-application] | Provide a application that might be started if the pipe does not exist.
+ -close | Closes a currently displayed notification.
*/
const allowedToasterFlags = [
't',
@@ -348,13 +376,16 @@ const allowedToasterFlags = [
'p',
'id',
's',
+ 'd',
'silent',
+ 'persistent',
'appID',
'pid',
'pipeName',
'close',
'install'
];
+
const toasterSoundPrefix = 'Notification.';
const toasterDefaultSound = 'Notification.Default';
module.exports.mapToWin8 = function (options) {
@@ -402,6 +433,11 @@ module.exports.mapToWin8 = function (options) {
delete options.sound;
}
+ if (options.wait === true) {
+ options.persistent = true;
+ delete options.wait;
+ }
+
if (options.s === false) {
options.silent = true;
delete options.s;