1. Application
  2. Launch at Startup

Application

Launch at Startup

This option lets you specify whether your desktop app should launch when a user starts their computer.

By default, this is disabled for Desktop apps and enabled for Menubar apps.

Enabling Launch at Startup

In the Application section, simply check the Launch at Startup By Default checkbox under App Options:

App Options panel for toggling Launch at Startup by Default

If enabled, your desktop app will now launch by default when a user starts up their computer.

Your users will always have an option to toggle this setting on or off in their native app menus (application menu and menubar/tray menu).

Using the Javascript API

We expose a launchSettings object and two helper methods if you wish to add custom logic to your app.

Get Launch Settings

window.todesktop.app.getLaunchSettings() returns a promise which resolves to a launchSettings object. This object has the following attributes:

Attribute Type Description
willLaunchAtStartup boolean The user's current setting for launching the app at startup.
        import { app } from '@todesktop/client-core';

const launchSettings = await app.getLaunchSettings();

console.log(launchSettings);
//  {
//    willLaunchAtStartup: true
//  }

      

Set Launch Settings

window.todesktop.app.setLaunchSettings(launchSettings) allows you to update a user's launch settings.

        import { app } from '@todesktop/client-core';

/*
 sets the value of willLaunchAtStartup to true
*/
app.setLaunchSettings({
  willLaunchAtStartup: true
});

      

Full example

The following is an example of how to toggle the status of Launch at Startup if a user clicks on a button.

        button.addEventListener('click', async () => {
  // Gets the launch settings object
  const { willLaunchAtStartup } = await app.getLaunchSettings();

  // toggles the value of will launch at startup
  app.setLaunchSettings({
    willLaunchAtStartup: !willLaunchAtStartup
  });
});