electron-demo.js/progress.js
tigerbot ee7a386421 implemented dock badges and progress bar
Not actually working on my system, but I don't know that has
	anything to do with the code in this repo.
2017-04-21 15:41:37 -06:00

35 lines
643 B
JavaScript

var electron = require('electron');
var app = electron.app;
var ipc = electron.ipcMain;
var win;
function init(window) {
if (win) {
console.error("can't initialize badge/progress tracker multiple times");
return;
}
win = window;
ipc.on('notification', function (ev, count) {
updateProgress(count);
increaseBadge();
});
win.on('focus', clearBadge);
}
function increaseBadge() {
if (!win.isFocused()) {
app.setBadgeCount(app.getBadgeCount() + 1);
}
}
function clearBadge() {
app.setBadgeCount(0);
}
function updateProgress(count) {
win.setProgressBar((count % 10)/10);
}
module.exports.init = init;