Skip to content

Commit

Permalink
Autostart with system and existing login items
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Skowronski committed Feb 5, 2017
1 parent 5e5dc3d commit af08691
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
40 changes: 22 additions & 18 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const {Menu} = require('electron')
const AutoLaunch = require('auto-launch');

require('electron-reload')(__dirname);
require('electron-debug')({showDevTools: false});
require('electron-debug')({showDevTools: true});

const MenuTemplate = require('./src/clipboard.js').template
const Keymap = require('./src/keymap.js')
Expand All @@ -14,31 +14,35 @@ const menuBarConfiguration = {
width: 400,
height: 600,
icon: __dirname + '/assets/keep.png',
preloadWindow: true
preloadWindow: false
}

var keeptronAutostart = new AutoLaunch({
name: 'Keeptron',
path: '/Applications/Keeptron.app',
});
const mb = menubar(menuBarConfiguration)

mb.on('after-create-window', function ready () {
mb.window.focus();
var appPath = mb.app.getPath('exe').split('.app/Content')[0] + '.app';

var keeptronAutostart = new AutoLaunch({
name: mb.app.getName(),
path: appPath,
});

keeptronAutostart.enable().then(function(isEnabled){
console.log(isEnabled)
});

keeptronAutostart.enable();
keeptronAutostart.isEnabled()
.then(function(isEnabled){
if(isEnabled){
keeptronAutostart.isEnabled()
.then(function(isEnabled){
console.log(isEnabled)
if(isEnabled){
return;
}
keeptronAutostart.enable();
})
.catch(function(err){
// handle error
});

const mb = menubar(menuBarConfiguration)

mb.on('after-create-window', function ready () {
mb.window.focus();
.catch(function(err){
console.log(err)
});
})

mb.app.on('ready', () => {
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "electron-quick-start",
"version": "1.0.0",
"description": "A minimal Electron application",
"name": "keeptron",
"version": "0.0.2",
"description": "Desktop Application for Google Keep",
"main": "main.js",
"scripts": {
"start": "electron ."
Expand All @@ -12,16 +12,16 @@
},
"keywords": [
"Electron",
"quick",
"keep",
"start",
"tutorial"
],
"author": "GitHub",
"license": "CC0-1.0",
"bugs": {
"url": "https://github.com/electron/electron-quick-start/issues"
"url": "https://github.com/ArturSkowronski/keeptron/issues"
},
"homepage": "https://github.com/electron/electron-quick-start#readme",
"homepage": "https://github.com/ArturSkowronski/keeptron",
"devDependencies": {
"electron": "^1.3.4"
},
Expand Down

0 comments on commit af08691

Please sign in to comment.