Giter VIP home page Giter VIP logo

go-autostart's Introduction

go-autostart

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

go-autostart's People

Contributors

aelphy avatar cuthix avatar emersion avatar meskio avatar pjebs avatar sanjanarajan avatar y-yagi avatar zhj4478 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-autostart's Issues

Problem with cross compilation for Windows

Hello.
I'm trying to compile code for windows from MacOS and Linux and I've got an error:

app.Enable undefined (type *autostart.App has no field or method Enable)

My code:

     if runtime.GOOS == "windows" {
		exe, _ := os.Executable()
		app := &autostart.App{
			Name:        "test",
			DisplayName: "test",
			Exec:        []string{exe},
		}
		app.Enable()
	}

how to achive the start in option

image

for windows10 how can i get the above option start in presently only we have got to start right but it got problem like it i starting the app from the startup folder.

Add option to start minimized in windows

In Windows, when enabling exe to start on boot, currently it opens a terminal on boot.
I would like to enable the program to run on boot, minimized.
Currently, go-autostart creates a shortcut in windows, I think that there's a way to control wether the shortcut opens minimized or it will open a windows.
The goal: I want to start the program shortcut on booth without any window, in background.

[Linux] Gnome fails to parse XDG desktop entry

The package seems to create a desktop file entry in accordance with the XDG specification at the path ~/.config/autostart. However, this file seem defective, as Gnome fails to parse them with the following journal error:

gnome-session-binary[1894]: WARNING: Could not parse desktop file ProtonMail Bridge.desktop or it references a not found TryExec binary

I believe this to be an issue with the double hyphenations in the "Exec" field. I see that you've tried working around the issue by escaping those, but it seems that Gnome fails to parse these properly (I'm guessing it works fine on other desktop environments).

On my system I've managed to apply an ugly hack in the form of:

Exec=sh -c "/usr/lib/protonmail/bridge/protonmail-bridge --no-window"

I'm not sure how presentable this solution is, but I was too lazy to come up with anything nicer.

[Windows] Unable to build

➜ GOOS=windows go build -ldflags "-H=windowsgui" .
# github.com/SkYNewZ/twitch-clip
./main.go:69:105: app.IsEnabled undefined (type *autostart.App has no field or method IsEnabled)
./main.go:92:13: app.IsEnabled undefined (type *autostart.App has no field or method IsEnabled)
./main.go:95:17: app.Disable undefined (type *autostart.App has no field or method Disable)
./main.go:103:17: app.Enable undefined (type *autostart.App has no field or method Enable)

➜ GOOS=linux go build .   # Another error                        
# github.com/getlantern/systray
../../../../pkg/mod/github.com/getlantern/[email protected]/systray.go:78:2: undefined: nativeLoop
../../../../pkg/mod/github.com/getlantern/[email protected]/systray.go:106:2: undefined: registerSystray
../../../../pkg/mod/github.com/getlantern/[email protected]/systray.go:111:14: undefined: quit
../../../../pkg/mod/github.com/getlantern/[email protected]/systray.go:136:2: undefined: addSeparator
../../../../pkg/mod/github.com/getlantern/[email protected]/systray.go:190:2: undefined: hideMenuItem
../../../../pkg/mod/github.com/getlantern/[email protected]/systray.go:195:2: undefined: showMenuItem
../../../../pkg/mod/github.com/getlantern/[email protected]/systray.go:220:2: undefined: addOrUpdateMenuItem

When building for Windows, I get this error. My program is building/running successfully on macOS.

Disable windows

How can I disable windows start up for this? I already made my own for windows

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.