autostart

package module
v0.0.0-...-6e07ff2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2022 License: MIT Imports: 5 Imported by: 0

README

go-autostart

fork from emersion/go-autostart, for removing cgo

GoDoc

A Go library to run a command after login.

Usage

package main

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

func main() {
	app := &autostart.App{
		Name: "test",
		DisplayName: "Just a Test App",
		Exec: []string{"sh", "-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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	// Unique identifier for the app.
	Name string
	// The command to execute, followed by its arguments.
	Exec []string
	// The app name.
	DisplayName string
	// The app icon.
	Icon string
}

An application that will be started when the user logs in.

func (*App) Disable

func (a *App) Disable() error

Disable this app on startup.

func (*App) Enable

func (a *App) Enable() error

Enable this app on startup.

func (*App) IsEnabled

func (a *App) IsEnabled() bool

Check if the app is enabled on startup.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL