From a0020270c872cac02efdbf936fca8c6ec2831652 Mon Sep 17 00:00:00 2001 From: Taylor Hanayik Date: Thu, 23 Feb 2017 10:41:41 -0500 Subject: [PATCH] update electron notifications and brightness check --- app.js | 28 +++++++++++++++++++++++++--- package.json | 1 + 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index 1364e82..55b67d3 100644 --- a/app.js +++ b/app.js @@ -11,6 +11,8 @@ const appRootDir = require('app-root-dir').get() //get the path of the applicati const ffmpeg = appRootDir+'/ffmpeg/ffmpeg' const exec = require( 'child_process' ).exec const system = require('system-control')(); +const notifier = require('electron-notifications') +app.setName("PNT") //icon credit: http://www.flaticon.com/authors/madebyoliver // Keep a global reference of the window object, if you don't, the window will @@ -43,12 +45,32 @@ function createWindow () { system.display.getBrightness().then(function(brightness) { console.log(brightness) if (brightness < 1) { - dialog.showMessageBox({ type: 'info', buttons: ['Adjust brightness for me', 'Cancel'], message: "Your screen seems a bit dim, would you like to set it to it's maximum setting? It's best to have it as bright as possible." }, function (buttonIndex) { - if (buttonIndex == 0) { + // dialog.showMessageBox({ type: 'info', buttons: ['Adjust brightness for me', 'Cancel'], message: "Your screen seems a bit dim, would you like to set it to it's maximum setting? It's best to have it as bright as possible." }, function (buttonIndex) { + // if (buttonIndex == 0) { + // maxBrightness = 1 + // system.display.setBrightness(maxBrightness).then(function() {}); + // } + // }); + // USE NOTIFICATIONS WHEN MY PR IS MERGED! + // + console.log('got here') + const notification = notifier.notify(app.getName(), { + message: "Your screen is dim.", + buttons: ['Illuminate', 'Cancel'], + duration: 20000 + }) + notification.on('buttonClicked', (text) => { + console.log(text) + if (text === 'Illuminate') { + console.log('Illuminate clicked!') maxBrightness = 1 system.display.setBrightness(maxBrightness).then(function() {}); } - }); + notification.close() + }) + notification.on('clicked', () => { + notification.close() + }) } }); } diff --git a/package.json b/package.json index e6f4837..3e6816b 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "dependencies": { "app-root-dir": "^1.0.2", "csvsync": "^1.0.1", + "electron-notifications": "^0.1.6", "jQuery": "^1.7.4", "moment": "^2.17.1", "system-control": "0.0.4",