autostarter

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2021 License: MIT Imports: 6 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Autostarter

GoDoc license

Autostarter is a Go library that creates a shortcut to run automatically at startup and supports cross-compilation between Windows and Linux

Getting Started

Installing

This assumes you already have a working Go environment, if not please see this page first.

go get github.com/danieloliveira085/autostarter
Usage

Import the package into your project.

import "github.com/danieloliveira085/autostarter"

Construct a new autostart that can be used to access the main functions of the autostart created

a := autostarter.NewAutostart(
	autostarter.Shortcut{
		Name:    "Shortcut name",
		Exec:    "Executable",
		Args:    []string{}, //Arguments, can be empty
		StartIn: "Path where executable starts", //If empty, the root of the executable will be defined as directory
	},
	autostarter.DefaultIcon, //Icon, for a custom icon, use SetIcon()
)

See Documentation on GoDoc for more detailed information.

Documentation

Index

Constants

View Source
const DefaultIcon icon = ""

Default icon, defined by OS

Variables

This section is empty.

Functions

func SetIcon

func SetIcon(path string) (icon, error)

Windows: Accepted formats: ico Linux: Accepted formats: ico, png, jpg

Types

type Autostart

type Autostart struct {
	// contains filtered or unexported fields
}

func NewAutostart

func NewAutostart(sc Shortcut, ic icon) *Autostart

Create a new autostart The startup with system is disabled by default, use Enable() to enable it or use IsEnabled () to check if this autostart has been enabled previously

func (*Autostart) Disable

func (a *Autostart) Disable() error

Disable the autostart

func (*Autostart) Enable

func (a *Autostart) Enable() error

Enable the autostart

func (*Autostart) IsEnabled

func (a *Autostart) IsEnabled() bool

Return TRUE if the autostart is enabled

func (*Autostart) Trigger

func (a *Autostart) Trigger() bool

If autostart is enabled, it deactivates and vice versa This return the state of autostart after the trigger

type Shortcut

type Shortcut struct {
	// Executable name
	Name string
	// Executable path, ex: windows: C:/Windows/explorer.exe linux: /usr/bin/gcc
	Exec string
	// The arguments for executable, can be empty
	Args []string
	// The directory where the executable starts, if empty, the root of the executable will be defined as directory
	StartIn string
}

Jump to

Keyboard shortcuts

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