Skip to content

Commit

Permalink
feat: implements proper timeout/wait behaviour for notify-send
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelbr committed Aug 10, 2020
1 parent 1c74ea9 commit b178da6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"printWidth": 80,
"singleQuote": true
"singleQuote": true,
"trailingComma": "none"
}
11 changes: 11 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,24 @@ module.exports.mapToNotifySend = function (options) {
options = mapAppIcon(options);
options = mapText(options);

if (options.timeout === false) {
delete options.timeout;
}
if (options.wait === true) {
options['expire-time'] = 5; // 5 seconds default time (multipled below)
}
for (var key in options) {
if (key === 'message' || key === 'title') continue;
if (options.hasOwnProperty(key) && notifySendFlags[key] !== key) {
options[notifySendFlags[key]] = options[key];
delete options[key];
}
}
if (typeof options['expire-time'] === 'undefined') {
options['expire-time'] = 10 * 1000; // 10 sec timeout by default
} else {
options['expire-time'] = options['expire-time'] * 1000; // notify send uses milliseconds
}

return options;
};
Expand Down

0 comments on commit b178da6

Please sign in to comment.