• Stars
    star
    910
  • Rank 48,256 (Top 1.0 %)
  • Language
    CoffeeScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Launch applications or executables at login (Mac, Windows, and Linux)

node-auto-launch

NPM version Build Status Windows Build Status Dependency Status


Auto-launch your app on login.

  • ⭐ Launch any application or executable at startup / login / boot.
  • ⭐ Supports Linux, FreeBSD, Mac (via AppleScript or Launch Agent), and Windows.
  • ⭐ Supports NW.js and Electron (with or without Squirrel; i.e. even if you're using Electron's built-in autoUpdater API).
  • ⭐ Auto-detects your app path for NW.js and Electron apps.
  • ⭐ Supports NW.js and Electron apps in Windows Store (with some caveats).
  • 😞 Not Mac App Store friendly. See Make this Mac App Store compatible for more information.

Usage

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

var minecraftAutoLauncher = new AutoLaunch({
	name: 'Minecraft',
	path: '/Applications/Minecraft.app',
});

minecraftAutoLauncher.enable();

//minecraftAutoLauncher.disable();


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

Installation

npm install --save auto-launch

API

new AutoLaunch(options)

options - Object

options.name - String

The name of your app.

options.path - String (optional for NW.js and Electron apps)

The absolute path to your app.

For NW.js and Electron apps, you don't have to specify the path. We guess based on process.execPath.

options.isHidden - (Optional) Boolean

If true, we instruct the operating system to launch your app in hidden mode when launching at login. Defaults to false.

options.mac (Optional) object

For Mac-only options.

options.mac.useLaunchAgent (optional) Boolean.

By default, we use AppleScript to add a Login Item. If this is true, we use a Launch Agent to auto-launch your app. Defaults to false. For more information, see How does it work? (mac) below.

.enable

Sets your app to auto-launch at startup. Returns a Promise.

.disable

Disables your app from auto-launching at startup. Returns a Promise.

.isEnabled()

Returns a Promise which resolves to a Boolean; true if your app is set to launch on startup.

How does it work?

Linux / FreeBSD

A Desktop Entry is created; i.e. a .desktop file is created in ~/.config/autostart/.

Note: if auto-launch is enabled and then your app is removed, this desktop entry file would be left behind on the user's machine.

Mac

AppleScript (default)

We execute an AppleScript command to instruct System Events to add or remove a Login Item for your app. There are no files involved. To see your Login Items, you can go to System Preferences, Users & Groups, then Login Items. End users can add or disable items (including your app) here also, but most typical users aren't aware of it.

Login Items screenshot

Note: This is not Mac App Store friendly; if you use it in your app, it will be rejected by the Mac App Store. We're only 99% sure on this as we haven't actually tried ourselves. See Make this Mac App Store compatible for more information.

Launch Agent

This is a file-based method like Linux's Desktop Entry method. We add a .plist file in the user's Library/LaunchAgents directory to create a Launch Agent for your app.

Pros

  • Launch Agents are intended for daemons / something without UI, which might be applicable depending on your app.
  • We think this method seems to be faster, as in to enable or disable auto-launching (there is no difference in the amount of time it takes your app to launch). Although, that's not really a concern.
  • You might not trust AppleScript.

Cons

  • Your app will not appear in the user's Login Items. Therefore the user can only toggle auto-launching inside your app, if you provide them with a setting of course (which you should!). This is not a huge deal as most users are not aware of Login Items preferences, but it would be ideal if your app appeared there.
  • If the user was to remove your app, the file would be left behind on the user's machine.

If you find that the AppleScript method doesn't work for you and this method does, please let us know by creating an issue.

Note: This is not Mac App Store friendly; if you use it in your app, it will be rejected by the Mac App Store as this reaches outside of the app sandbox. See Make this Mac App Store compatible for more information.

Windows

We add a registry entry under \HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run.

Note: If the user was to remove your app, this would be left in the registry, but that's not such a big deal. You can probably configure your uninstaller to unset it.

Squirrel.Windows

If you're using Squirrel.Windows, i.e. what's underneath Electron's built-in autoUpdater API on Windows, we add a registry entry for your app's Update.exe instead of your actual application. This is due to how Squirrel.Windows works under the hood. What if we didn't? Well, if the user started / restarted their machine after updating your app, it would launch the old version by mistake.

Windows App Store apps

If you have your Electron-based app in the Windows Store and would like to include auto launch functionality, simply linking to the executable path will not work. The Appx packages required for Electron are sandboxed and the install location can only be accessed by the system itself.

There is a way to bypass that - it will require you to know the developer ID, app ID and package name of your app. Then, instead of using the exec path, you will need to set the path in AutoLaunch() config to: explorer.exe shell:AppsFolder\DEV_ID.APP_ID!PACKAGE_NAME. You can find your apps details by following this article. Note that you might need to compile and submit your app to the store first to obtain these details.

Would you like to contribute?

We're always open to your help and feedback. See our CONTRIBUTING.md.

More Repositories

1

reload

Lightweight automatic reloading of Go processes.
Go
187
star
2

android-clean-architecture

Showcasing a Clean Architecture approach from our Android applications framework!
Kotlin
162
star
3

s3zipper

Simple Steaming S3 File Zipper Microservice - works with any backend via redis and redirection.
Go
87
star
4

github-sync

This action helps you to sync your PRs with tasks in Teamwork to streamline team collaboration and your development workflows.
Shell
64
star
5

clippy.desktop

Bringing Clippy back to the desktop (including Mac and Linux)
JavaScript
63
star
6

visual-dom-diff

Highlight differences between two DOM trees.
HTML
40
star
7

kommentaar

Generate documentation for Go APIs
Go
33
star
8

s3pp

A package to help you create POST policies to upload files directly to Amazon S3
Go
32
star
9

node-afk

Away from keyboard!
JavaScript
32
star
10

nylas-go

Go client for the Nylas API v2
Go
18
star
11

stripehooks

A server to handle Stripe webhooks with customizable handlers
Go
16
star
12

vscode-projects

Teamwork Projects VSCode Extension
TypeScript
16
star
13

tnef

Go library to extract body and attachments from TNEF files
Go
16
star
14

progressive-web-app-template

A starting point to get you started with creating or converting your existing website/webapp into a Progressive Web App. Includes a service worker template.
HTML
14
star
15

codesamples

Code samples supporting our developer documentation
Java
13
star
16

api-examples

API Examples for interacting with Teamwork.com products
Python
11
star
17

utils

A collection of small and often used extensions to Go's standard library
Go
11
star
18

android-multiautocomplete

A lightweight and powerful abstraction over MultiAutoCompleteTextView and Tokenizer
Java
9
star
19

vue-dropdown-directive

A vue.js directive for handling dropdowns
JavaScript
9
star
20

mailaddress

Mail address parsing library for Go
Go
8
star
21

gulp-path-length

A Gulp plugin for enforcing a character limit on file paths
CoffeeScript
8
star
22

guru

Go errors with a Guru Meditation Number
Go
7
star
23

mobile-design-system

Swift
6
star
24

autocomplete

An autocomplete module for all text editors and frameworks.
TypeScript
6
star
25

serverless-crash-reporting

A serverless webtask/function for handling crash reports from Electron apps (for use with Webtask.io)
JavaScript
6
star
26

markdown-editor

An advanced markdown editor used in the Teamwork product suite.
TypeScript
6
star
27

middleware

Collection of Go HTTP middleware
Go
5
star
28

dotnet

Teamwork API Libraries for .Net Framework and .Net Core
C#
5
star
29

validate

Simple validation
Go
5
star
30

ot-rich-text

Format for representing rich-text documents and changes.
JavaScript
5
star
31

vat

VAT matching and validation in Go
Go
3
star
32

watcher

Watcher for restarting your project when any changes are made.
Go
2
star
33

hackathon-tidytasks

Alder, Maeve, Rory & Brendan's Hackathon Nov. 2017
CSS
2
star
34

toutf8

Convert text to UTF-8
Go
2
star
35

godocgen

Generate self-contained HTML documentation with godoc.
HTML
2
star
36

TeamworkAPICFC

Teamwork.com API CFC for ColdFusion
ColdFusion
1
star
37

htmltotext

Converts HTML to plain text
Shell
1
star
38

asbyte

Print data as Go byte slices
Go
1
star
39

mailstrip

Reupload of deleted Go port of Mailgun's reply ripping library
Go
1
star