Emitter.on('settings:set', (event, details) => {
  Settings.set(details.key, details.value);
  // DEV: React to settings change
  switch (details.key) {
    case 'miniAlwaysShowSongInfo':
      Emitter.sendToGooglePlayMusic('miniAlwaysShowSongInfo', { state: details.value });
      break;
    case 'miniAlwaysOnTop':
      Emitter.sendToGooglePlayMusic('miniAlwaysOnTop', { state: details.value });
      break;
    case 'miniUseScrollVolume':
      Emitter.sendToGooglePlayMusic('miniUseScrollVolume', { state: details.value });
      break;
    case 'speechRecognition':
      Emitter.sendToGooglePlayMusic('speech:toggle', { state: details.value });
      break;
    case 'scrollLyrics':
      Emitter.sendToAll('settings:set:scrollLyrics', details.value);
      break;
    case 'auto-launch':
      if (details.value === true) {
        appLauncher.enable();
      } else {
        appLauncher.disable();
      }
      break;
    default:
      break;
  }
});
Beispiel #2
0
exports.autoload = (on) => {
	if (options.autoload) {
		launcher.enable();
	} else {
		launcher.disable();
	}
};
 appLauncher.isEnabled().then(function(enabled){
   if(enabled) {
     appLauncher.disable();
   } else {
     return appLauncher.enable();
   }
 }).then(function(err){
Beispiel #4
0
        this.autoLaunch.isEnabled().then(enabled => {
            if (enabled) {
                if (!state) this.autoLaunch.disable();
                return;
            }

            if (state) this.autoLaunch.enable();
        });
Beispiel #5
0
		click: function(item) {
			if ( item.checked ) {
				appLauncher.enable();
				globalSettings.set('auto_launch', 1);
			} else {
				appLauncher.disable();
				globalSettings.set('auto_launch', 0);
			}
			globalSettings.save();
		}
Beispiel #6
0
function startupClicked()
{
	if (startup.checked)
	{
		runatstartup.enable();
	}
	else
	{
		runatstartup.disable();
	}
}
 autoLaunchCahnge: function () {
   if (this.auto_launch) {
     appLauncher.enable(function(err) {
       if (!err) {
         localStorage.setItem('auto_launch', true);
       }
     });
   } else {
     appLauncher.disable(function(err) {
       if (!err) {
         localStorage.setItem('auto_launch', false);
       }
     });
   }
 }
Beispiel #8
0
    startup: function() {
        var nimbleAutoLauncher = new AutoLaunch({
            name: 'Nimble',
            path: path.resolve(app.getAppPath(), '../../../')
        });

        // startup?
        if (global.options.startup === true) {
            nimbleAutoLauncher.enable();
        } else {
            nimbleAutoLauncher.disable();
        }

        return null
    },
Beispiel #9
0
async function setupAutoLaunch(cmd) {
  const appLauncher = new AutoLaunch({
    name: app.getName(),
    isHidden: true,
  });
  if (cmd === '--squirrel-uninstall') {
    // If we're uninstalling, make sure we also delete our auto launch registry key
    await appLauncher.disable();
  } else if (cmd === '--squirrel-install' || cmd === '--squirrel-updated') {
    // If we're updating and already have an registry entry for auto launch, make sure to update the path
    const enabled = await appLauncher.isEnabled();
    if (enabled) {
      await appLauncher.enable();
    }
  }
}
Beispiel #10
0
        launcher.isEnabled(function(enabled) {
          if (settings.launchOnStartup && !enabled) {
            launcher.enable(function(error) {
              if (error) {
                console.error(error);
              }
            });
          }

          if (!settings.launchOnStartup && enabled) {
            launcher.disable(function(error) {
              if (error) {
                console.error(error);
              }
            });
          }
        });
Beispiel #11
0
function getConfig() {
	try {
		let dataPath = path.join(mb.app.getPath('userData'), 'config.json');
		let data = JSON.parse(fs.readFileSync(dataPath));

		workTimer = data.workTimer * 60 * 1000;
		relaxTimer = data.relaxTimer * 60 * 1000;
		longRelaxTimer = data.longRelaxTimer * 60 * 1000;
    showTimer = data.showTimer;
		launchOnStartup = data.launchOnStartup;

		(launchOnStartup ? autolauncher.enable() : autolauncher.disable())
		.then(function(err) {
			dialog.showErrorBox('Error on adding launch on startup functionality', err);
		});
	} catch(err) {
		console.log(err);
		console.log('Didn\'t find previous config. Using default settings');
	}
}
const setAutoLaunch = AutoLaunchValue => {
	// Don't run this in development
	if (isDev) {
		return;
	}

	// On Mac, work around a bug in auto-launch where it opens a Terminal window
	// See https://github.com/Teamwork/node-auto-launch/issues/28#issuecomment-222194437

	const appPath = process.platform === 'darwin' ? app.getPath('exe').replace(/\.app\/Content.*/, '.app') : undefined; // Use the default

	const ZulipAutoLauncher = new AutoLaunch({
		name: 'Zulip',
		path: appPath,
		isHidden: false
	});
	const autoLaunchOption = ConfigUtil.getConfigItem('startAtLogin', AutoLaunchValue);

	if (autoLaunchOption) {
		ZulipAutoLauncher.enable();
	} else {
		ZulipAutoLauncher.disable();
	}
};
Beispiel #13
0
 appLauncher.isEnabled().then((enabled) => {
     if (enabled) {
         return
     }
     return appLauncher.enable()
 }).then((enabled) => {
Beispiel #14
0
}

if ("production" === environment) {

    var AutoLaunch = require('auto-launch');

    var autoLaunch = new AutoLaunch({
        name: packageJson.name
    });

    autoLaunch.enable(function(error){

    	if (error) {
    		console.error(error);
    	} else {
    		console.log("autolaunch has been enabled");
    	}

    });

}

var menubar = require('menubar')({

    "dir": __dirname,
    "index": 'file://' + __dirname + '/container.html',
    "name" : packageJson.name,
    "title" : packageJson.name,
    "width": 320,
    "height": 480,
Beispiel #15
0
 .then(enabled => {
   if (!enabled) return appLauncher.enable()
 })
const AutoLaunch = require('auto-launch');

/**
 * Add the app to auto-launch.
 */

var autolaunch = new AutoLaunch({
  name: 'Make Me Move'
    //isHidden: true // hidden on launch - only works on a mac atm.
});

if (process.env.ENVIRONMENT !== 'DEV') {
  autolaunch.enable();
}
Beispiel #17
0
exports.setAutoload = (fn) => {
	launcher.enable();
}
app.on('ready', async () => {
  await installExtensions();

  tray = new Tray(iconIdle);

  function comfirmUpdate(updater) {
    dialog.showMessageBox({
      type: 'question',
      buttons: ['Update & Restart', 'Cancel'],
      title: 'Update available',
      cancelId: 99,
      message: 'There is an update available. Would you like to update and restart now?'
    }, (response) => {
      console.log(`Exit: ${response}`);
      app.dock.hide();
      if (response === 0) {
        updater.install();
      }
    });
  }

  function checkUpdate(showAlert) {
    const updateOptions = {
      repo: 'uraway/todo-electron',
      currentVersion: app.getVersion()
    };

    const updater = new GhReleases(updateOptions);

    updater.on('error', (event, message) => {
      console.log(`Event: ${JSON.stringify(event)}. Message: ${message}`);
    });

    updater.on('update-downloaded', () => {
      comfirmUpdate(updater);
    });

    updater.check((err, status) => {
      if (err || !status) {
        if (showAlert) {
          dialog.showMessageBox({
            type: 'info',
            buttons: ['Close'],
            title: 'No update available',
            message: 'You are currently running the latest version.'
          });
        }
        app.dock.hide();
      }
      if (!err && status) {
        updater.download();
      }
    });
  }

  function initMenu() {
    template = [{
      label: 'Electron',
      submenu: [{
        label: 'About ElectronReact',
        selector: 'orderFrontStandardAboutPanel:'
      }, {
        type: 'separator'
      }, {
        label: 'Services',
        submenu: []
      }, {
        type: 'separator'
      }, {
        label: 'Hide ElectronReact',
        accelerator: 'Command+H',
        selector: 'hide:'
      }, {
        label: 'Hide Others',
        accelerator: 'Command+Shift+H',
        selector: 'hideOtherApplications:'
      }, {
        label: 'Show All',
        selector: 'unhideAllApplications:'
      }]
    }, {
      label: 'Edit',
      submenu: [{
        label: 'Undo',
        accelerator: 'Command+Z',
        selector: 'undo:'
      }, {
        label: 'Redo',
        accelerator: 'Shift+Command+Z',
        selector: 'redo:'
      }, {
        type: 'separator'
      }, {
        label: 'Cut',
        accelerator: 'Command+X',
        selector: 'cut:'
      }, {
        label: 'Copy',
        accelerator: 'Command+C',
        selector: 'copy:'
      }, {
        label: 'Paste',
        accelerator: 'Command+V',
        selector: 'paste:'
      }, {
        label: 'Select All',
        accelerator: 'Command+A',
        selector: 'selectAll:'
      }]
    }, {
      label: 'View',
      submenu: (isDevelopment) ? [{
        label: 'Reload',
        accelerator: 'Command+R',
        click() {
          tray.window.webContents.reload();
        }
      }, {
        label: 'Toggle Full Screen',
        accelerator: 'Ctrl+Command+F',
        click() {
          tray.window.setFullScreen(!tray.window.isFullScreen());
        }
      }, {
        label: 'Toggle Developer Tools',
        accelerator: 'Alt+Command+I',
        click() {
          tray.window.toggleDevTools();
        }
      }] : [{
        label: 'Toggle Full Screen',
        accelerator: 'Ctrl+Command+F',
        click() {
          tray.window.setFullScreen(!tray.isFullScreen());
        }
      }]
    }, {
      label: 'Window',
      submenu: [{
        label: 'Minimize',
        accelerator: 'Command+M',
        selector: 'performMiniaturize:'
      }, {
        label: 'Close',
        accelerator: 'Command+W',
        selector: 'performClose:'
      }, {
        type: 'separator'
      }, {
        label: 'Bring All to Front',
        selector: 'arrangeInFront:'
      }]
    }, {
      label: 'Help',
      submenu: [{
        label: 'Learn More',
        click() {
          shell.openExternal('http://electron.atom.io');
        }
      }, {
        label: 'Documentation',
        click() {
          shell.openExternal('https://github.com/atom/electron/tree/master/docs#readme');
        }
      }, {
        label: 'Community Discussions',
        click() {
          shell.openExternal('https://discuss.atom.io/c/electron');
        }
      }, {
        label: 'Search Issues',
        click() {
          shell.openExternal('https://github.com/atom/electron/issues');
        }
      }]
    }];

    menu = Menu.buildFromTemplate(template);
    Menu.setApplicationMenu(menu);
  }

  function hideWindow() {
    if (!tray.window) return;
    tray.window.hide();
  }

  function initWindow() {
    const defaults = {
      width: 500,
      height: 728,
      show: false,
      frame: false
    };

    tray.window = new BrowserWindow(defaults);
    tray.window.loadURL(`file://${__dirname}/index.html`);
    if (isDevelopment) {
      tray.window.toggleDevTools();
    }
    tray.window.on('blur', hideWindow);

    initMenu();
    checkUpdate(false);
  }

  function showWindow() {
    tray.window.show();
  }

  initWindow();

  tray.on('click', (e) => {
    if (e.altKey || e.shiftKey || e.ctrlKey || e.metaKey) { return hideWindow(); }
    if (tray.window && tray.window.isVisible()) { return hideWindow(); }
    showWindow();
  });

  tray.window.on('closed', () => {
    hideWindow();
  });

  autoStart.enable();

  tray.setToolTip('Todo notifications');
});
Beispiel #19
0
appLauncher.isEnabled().then(function(enabled){
	if(enabled) return;
	return appLauncher.enable();
}).then(function(err){
Beispiel #20
0
 ipcMain.on('startup-enable', () => autoStart.enable());
Beispiel #21
0
 ipc.on('startup-enable', function() {
   autoStart.enable();
 });