Commit 1e6b1647e26288549bebc55695f9cc0670926609
Make browser configurable
cel committed on 1/29/2020, 4:17:47 PMParent: 59aafa980de6d5befab14da423568670e1634590
Files changed
README.md | changed |
index.js | changed |
notifier.js | changed |
README.md | |||
---|---|---|---|
@@ -24,12 +24,14 @@ | |||
24 | 24 … | ``` | |
25 | 25 … | { | |
26 | 26 … | "notifications": { | |
27 | 27 … | "msgBaseUrl": "http://localhost:8989/msg/" | |
28 … | + "browser": "x-www-browser" | ||
28 | 29 … | } | |
29 | 30 … | } | |
30 | 31 … | ``` | |
31 | 32 … | - `msgBaseUrl`: base url to open when activating a notification about a message. Default is the one hosted by ssb-ws. | |
33 … | +- `browser`: Browser or command to open the message URL if using freedesktop-notifications. Default is `x-www-browser`. | ||
32 | 34 … | ||
33 | 35 … | ## License | |
34 | 36 … | ||
35 | 37 … | Copyright 2016, 2017, 2010 Charles Lehner |
index.js | ||
---|---|---|
@@ -15,9 +15,9 @@ | ||
15 | 15 … | logOpts.old = true |
16 | 16 … | logOpts.gte = Date.now() - conf.recent |
17 | 17 … | } |
18 | 18 … | |
19 | - require('./notifier')(appName, function (err, _notify) { | |
19 … | + require('./notifier')(appName, config, function (err, _notify) { | |
20 | 20 … | if (err) return console.error('[notifier]', err.message || err) |
21 | 21 … | notify = _notify |
22 | 22 … | pull( |
23 | 23 … | sbot.createLogStream(logOpts), |
notifier.js | ||
---|---|---|
@@ -1,10 +1,12 @@ | ||
1 | -module.exports = function init(appName, cb) { | |
1 … | +module.exports = function init(appName, config, cb) { | |
2 … | + var conf = config && config.notifier || {} | |
2 | 3 … | switch (require('os').type()) { |
3 | 4 … | |
4 | 5 … | case 'Linux': |
5 | 6 … | var proc = require('child_process') |
6 | 7 … | var notifications = require('freedesktop-notifications') |
8 … | + var browser = conf.browser || 'x-www-browser' | |
7 | 9 … | try { |
8 | 10 … | return notifications.init(inited) |
9 | 11 … | } catch(e) { |
10 | 12 … | // fallthrough |
@@ -28,9 +30,9 @@ | ||
28 | 30 … | // https://developer.gnome.org/notification-spec/#hints |
29 | 31 … | 'desktop-entry': 'ssb-patchwork-electron' |
30 | 32 … | }) |
31 | 33 … | notification.on('action', function (action) { |
32 | - proc.spawn('xdg-open', [notif.open], {stdio: 'inherit'}).unref() | |
34 … | + proc.spawn(browser, [notif.open], {stdio: 'inherit'}).unref() | |
33 | 35 … | }); |
34 | 36 … | notification.push() |
35 | 37 … | }) |
36 | 38 … | } |
Built with git-ssb-web