git ssb

0+

cel / ssb-notifier



Commit 1e6b1647e26288549bebc55695f9cc0670926609

Make browser configurable

cel committed on 1/29/2020, 4:17:47 PM
Parent: 59aafa980de6d5befab14da423568670e1634590

Files changed

README.mdchanged
index.jschanged
notifier.jschanged
README.mdView
@@ -24,12 +24,14 @@
2424 ```
2525 {
2626 "notifications": {
2727 "msgBaseUrl": "http://localhost:8989/msg/"
28 + "browser": "x-www-browser"
2829 }
2930 }
3031 ```
3132 - `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`.
3234
3335 ## License
3436
3537 Copyright 2016, 2017, 2010 Charles Lehner
index.jsView
@@ -15,9 +15,9 @@
1515 logOpts.old = true
1616 logOpts.gte = Date.now() - conf.recent
1717 }
1818
19- require('./notifier')(appName, function (err, _notify) {
19 + require('./notifier')(appName, config, function (err, _notify) {
2020 if (err) return console.error('[notifier]', err.message || err)
2121 notify = _notify
2222 pull(
2323 sbot.createLogStream(logOpts),
notifier.jsView
@@ -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 || {}
23 switch (require('os').type()) {
34
45 case 'Linux':
56 var proc = require('child_process')
67 var notifications = require('freedesktop-notifications')
8 + var browser = conf.browser || 'x-www-browser'
79 try {
810 return notifications.init(inited)
911 } catch(e) {
1012 // fallthrough
@@ -28,9 +30,9 @@
2830 // https://developer.gnome.org/notification-spec/#hints
2931 'desktop-entry': 'ssb-patchwork-electron'
3032 })
3133 notification.on('action', function (action) {
32- proc.spawn('xdg-open', [notif.open], {stdio: 'inherit'}).unref()
34 + proc.spawn(browser, [notif.open], {stdio: 'inherit'}).unref()
3335 });
3436 notification.push()
3537 })
3638 }

Built with git-ssb-web