mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 12:38:39 -09:00
29 lines
674 B
JavaScript
29 lines
674 B
JavaScript
const { app, BrowserWindow } = require('electron');
|
|
const isDev = require('electron-is-dev');
|
|
const { resolve } = require('path');
|
|
|
|
let win;
|
|
|
|
// the hack of all hacks
|
|
// electron doesn't have a built in notification thing,
|
|
// so we launch a window on which we can use the
|
|
// HTML5 `Notification` API :'(
|
|
|
|
app.on('ready', () => {
|
|
const win_ = new BrowserWindow({
|
|
show: false
|
|
});
|
|
const url = 'file://' + resolve(
|
|
isDev ? __dirname : app.getAppPath(),
|
|
'notify.html'
|
|
);
|
|
win_.loadURL(url);
|
|
win = win_;
|
|
});
|
|
|
|
module.exports = function notify (title, body) {
|
|
if (win) {
|
|
win.webContents.send('notification', { title, body });
|
|
}
|
|
// TODO: buffer ?
|
|
};
|