/go-autostart

A Go library to run a command after login

Primary LanguageGoMIT LicenseMIT

go-autostart

GoDoc

A Go library to run a command after login.

Usage

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

License

MIT