Skip to content

Commit

Permalink
update electron notifications and brightness check
Browse files Browse the repository at this point in the history
  • Loading branch information
hanayik committed Feb 23, 2017
1 parent cc6b2c0 commit a002027
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
28 changes: 25 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
})
}
});
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit a002027

Please sign in to comment.