# user-startup

> Automatically run commands when the user logs in (cross-platform)

Latest version **0.2.2** (published 2016-08-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install user-startup
pnpm add user-startup
yarn add user-startup
bun add user-startup
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2016-08-30 |
| First published | 2015-08-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 129 |
| Author | Typicode |
| Maintainers | typicode |
| Keywords | startup, autostart, launchctl, plist, daemon, osx, linux, windows |

## Links

- npm: https://www.npmjs.com/package/user-startup
- Repository: https://github.com/typicode/user-startup
- Issues: https://github.com/typicode/user-startup/issues
- npm.io page: https://npm.io/package/user-startup

## Dependencies (2)

- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [untildify](https://npm.io/package/untildify.md) ^2.1.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.2.2 (latest) — 2016-08-30
- 0.2.1 — 2015-11-02
- 0.2.0 — 2015-10-13
- 0.1.1 — 2015-08-09
- 0.1.0 — 2015-08-03

## README

# user-startup [![Build Status](https://travis-ci.org/typicode/user-startup.svg)](https://travis-ci.org/typicode/user-startup) [![npm version](https://badge.fury.io/js/user-startup.svg)](https://www.npmjs.com/package/user-startup)

> Automatically run commands when the user logs in. Used in [hotel](https://github.com/typicode/hotel) and [stop-server](https://github.com/typicode/stop-server).

  * __No admin privileges required__
  * Cross-platform (OS X, Linux and Windows)

## Install

```
npm install user-startup --save
```

## Example

```javascript
const startup = require('user-startup')

const nodePath = process.execPath
const args = ['/some/path/app.js']
const out = '/some/path/out.log'

// Creates startup script and spawns process
startup.create('my-script', nodePath, args, out)

// Removes startup script
startup.remove('my-script')
```

Note: you should check that root isn't running this code to avoid startup scripts being created in root's home directory. Use [sudo-block](https://github.com/sindresorhus/sudo-block) or [is-root](https://github.com/sindresorhus/is-root).

## API

`add(id, cmd[, args[, out]])`

* `id <String>` id
* `cmd <String>` command
* `args <Array>` optional list of string arguments
* `out <String>` optional path to output file (directory needs to exist before)

Creates startup script.

`create(id, cmd[, args[, out]])`

Creates a startup script __and__ spawns process.

`remove(id)`

Removes startup script.

`dir`

Returns startup script directory.

`getFile(id)`

Returns startup script path.

## How it works

* On OS X, it creates a `plist` file in  `~/Library/LaunchAgents`
* On Linux, it creates a `desktop` file in `~/.config/autostart`
* On Windows, it creates a `vbs` script in `AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup`

## License

MIT - [Typicode](https://github.com/typicode)

---
_Source: https://npm.io/package/user-startup · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
