summaryrefslogtreecommitdiff
path: root/vendor/github.com/ProtonMail/go-autostart/README.md
blob: 580862f96b86023cc5a6fd0ffd7250f6c9e5a9d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# go-autostart

[![GoDoc](https://godoc.org/github.com/ProtonMail/go-autostart?status.svg)](https://godoc.org/github.com/ProtonMail/go-autostart)

A Go library to run a command after login.

## Usage

```go
package main

import (
	"log"
	"github.com/ProtonMail/go-autostart"
)

func main() {
	app := &autostart.App{
		Name: "test",
		DisplayName: "Just a Test App",
		Exec: []string{"bash", "-c", "echo autostart >> ~/autostart.txt"},
	}

	if app.IsEnabled() {
		log.Println("App is already enabled, removing it...")

		if err := app.Disable(); err != nil {
			log.Fatal(err)
		}
	} else {
		log.Println("Enabling app...")

		if err := app.Enable(); err != nil {
			log.Fatal(err)
		}
	}

	log.Println("Done!")
}
```

## Behavior

* On Linux and BSD, it creates a `.desktop` file in `$XDG_CONFIG_HOME/autostart`
  (i.e. `$HOME/.config/autostart`). See http://askubuntu.com/questions/48321/how-do-i-start-applications-automatically-on-login
* On macOS, it creates a `launchd` job. See http://blog.gordn.org/2015/03/implementing-run-on-login-for-your-node.html
* On Windows, it creates a link to the program in `%USERPROFILE%\Start Menu\Programs\Startup`

## License

MIT