@@ -28,6 +28,10 @@ const inArray = function (arr, val) {
28
28
return arr . indexOf ( val ) !== - 1 ;
29
29
} ;
30
30
31
+ /*
32
+ notifySend Flags
33
+ */
34
+
31
35
const notifySendFlags = {
32
36
u : 'urgency' ,
33
37
urgency : 'urgency' ,
@@ -81,6 +85,7 @@ module.exports.fileCommandJson = function (notifier, options, cb) {
81
85
console . info ( '[notifier path]' , notifier ) ;
82
86
console . info ( '[notifier options]' , options . join ( ' ' ) ) ;
83
87
}
88
+
84
89
return cp . execFile ( notifier , options , function ( error , stdout , stderr ) {
85
90
if ( error ) return cb ( error , stdout ) ;
86
91
if ( ! stdout ) return cb ( error , { } ) ;
@@ -161,16 +166,19 @@ module.exports.mapToNotifySend = function (options) {
161
166
if ( options . timeout === false ) {
162
167
delete options . timeout ;
163
168
}
169
+
164
170
if ( options . wait === true ) {
165
171
options [ 'expire-time' ] = 5 ; // 5 seconds default time (multipled below)
166
172
}
173
+
167
174
for ( const key in options ) {
168
175
if ( key === 'message' || key === 'title' ) continue ;
169
176
if ( options . hasOwnProperty ( key ) && notifySendFlags [ key ] !== key ) {
170
177
options [ notifySendFlags [ key ] ] = options [ key ] ;
171
178
delete options [ key ] ;
172
179
}
173
180
}
181
+
174
182
if ( typeof options [ 'expire-time' ] === 'undefined' ) {
175
183
options [ 'expire-time' ] = 10 * 1000 ; // 10 sec timeout by default
176
184
} else if ( typeof options [ 'expire-time' ] === 'number' ) {
@@ -215,10 +223,19 @@ module.exports.mapToMac = function (options) {
215
223
options . sound = 'Bottle' ;
216
224
}
217
225
226
+ /*
227
+ wait : Wait with callback, until user action is taken against notification,
228
+ does not apply to Windows Toasters as they always wait or notify-send
229
+ as it does not support the wait option
230
+
231
+ timeout : Takes precedence over wait if both are defined.
232
+ */
233
+
218
234
if ( options . wait === true ) {
219
235
if ( ! options . timeout ) {
220
236
options . timeout = 5 ;
221
237
}
238
+
222
239
delete options . wait ;
223
240
}
224
241
@@ -325,20 +342,31 @@ function removeNewLines(str) {
325
342
}
326
343
327
344
/*
328
- ---- Options ----
329
- [-t] <title string> | Displayed on the first line of the toast.
330
- [-m] <message string> | Displayed on the remaining lines, wrapped.
331
- [-b] <button1;button2 string>| Displayed on the bottom line, can list multiple buttons separated by ";"
332
- [-tb] | Displayed a textbox on the bottom line, only if buttons are not presented.
333
- [-p] <image URI> | Display toast with an image, local files only.
334
- [-id] <id> | sets the id for a notification to be able to close it later.
335
- [-s] <sound URI> | Sets the sound of the notifications, for possible values see http://msdn.microsoft.com/en-us/library/windows/apps/hh761492.aspx.
336
- [-silent] | Don't play a sound file when showing the notifications.
337
- [-appID] <App.ID> | Don't create a shortcut but use the provided app id.
338
- [-pid] <pid> | Query the appid for the process <pid>, use -appID as fallback. (Only relevant for applications that might be packaged for the store)
339
- [-pipeName] <\.\pipe\pipeName\> | Provide a name pipe which is used for callbacks.
340
- [-application] <C:\foo.exe> | Provide a application that might be started if the pipe does not exist.
341
- -close <id> | Closes a currently displayed notification.
345
+ Ntfy Toast / Toaster
346
+
347
+ Windows 10 & 11 use ntfy-toast library to send notifications:
348
+ https://github.com/Aetherinox/ntfy-toast
349
+
350
+ ntfy-toast has a special parameter for ensuring that notifications stick and do dismiss
351
+ unless the user physically dismisses them by using:
352
+ -persistent
353
+
354
+ ---- Options ----
355
+ [-t] <title string> | Displayed on the first line of the toast.
356
+ [-m] <message string> | Displayed on the remaining lines, wrapped.
357
+ [-b] <button1;button2 string> | Displayed on the bottom line, can list multiple buttons separated by ";"
358
+ [-tb] | Displayed a textbox on the bottom line, only if buttons are not presented.
359
+ [-p] <image URI> | Display toast with an image, local files only.
360
+ [-id] <id> | sets the id for a notification to be able to close it later.
361
+ [-s] <sound URI> | Sets the sound of the notifications, for possible values see http://msdn.microsoft.com/en-us/library/windows/apps/hh761492.aspx.
362
+ [-silent] | Don't play a sound file when showing the notifications.
363
+ [-persistent] | Makes the notification stick until the user dismisses it.
364
+ [-d] (short | long) | Set the duration default is "short" 7s, "long" is 25s.
365
+ [-appID] <App.ID> | Don't create a shortcut but use the provided app id.
366
+ [-pid] <pid> | Query the appid for the process <pid>, use -appID as fallback. (Only relevant for applications that might be packaged for the store)
367
+ [-pipeName] <\.\pipe\pipeName\> | Provide a name pipe which is used for callbacks.
368
+ [-application] <C:\foo.exe> | Provide a application that might be started if the pipe does not exist.
369
+ -close <id> | Closes a currently displayed notification.
342
370
*/
343
371
const allowedToasterFlags = [
344
372
't' ,
@@ -348,13 +376,16 @@ const allowedToasterFlags = [
348
376
'p' ,
349
377
'id' ,
350
378
's' ,
379
+ 'd' ,
351
380
'silent' ,
381
+ 'persistent' ,
352
382
'appID' ,
353
383
'pid' ,
354
384
'pipeName' ,
355
385
'close' ,
356
386
'install'
357
387
] ;
388
+
358
389
const toasterSoundPrefix = 'Notification.' ;
359
390
const toasterDefaultSound = 'Notification.Default' ;
360
391
module . exports . mapToWin8 = function ( options ) {
@@ -402,6 +433,11 @@ module.exports.mapToWin8 = function (options) {
402
433
delete options . sound ;
403
434
}
404
435
436
+ if ( options . wait === true ) {
437
+ options . persistent = true ;
438
+ delete options . wait ;
439
+ }
440
+
405
441
if ( options . s === false ) {
406
442
options . silent = true ;
407
443
delete options . s ;
0 commit comments