diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2019-08-08 00:19:33 +0200 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2019-08-08 00:19:33 +0200 |
commit | fde18e485ff7cbc7b2e33dade8e81136f06a5b60 (patch) | |
tree | 79a6dbd13e7e4a46e708a70104c548f403b477ae /vendor/github.com/ProtonMail/go-autostart/autostart_darwin.go | |
parent | 93e1de570f47b095905835735dbd67479aa0c2de (diff) |
[pkg] remove vendor
Diffstat (limited to 'vendor/github.com/ProtonMail/go-autostart/autostart_darwin.go')
-rw-r--r-- | vendor/github.com/ProtonMail/go-autostart/autostart_darwin.go | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/vendor/github.com/ProtonMail/go-autostart/autostart_darwin.go b/vendor/github.com/ProtonMail/go-autostart/autostart_darwin.go deleted file mode 100644 index b2e0518..0000000 --- a/vendor/github.com/ProtonMail/go-autostart/autostart_darwin.go +++ /dev/null @@ -1,66 +0,0 @@ -package autostart - -import ( - "os" - "path/filepath" - "text/template" -) - -const jobTemplate = `<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> -<plist version="1.0"> - <dict> - <key>Label</key> - <string>{{.Name}}</string> - <key>ProgramArguments</key> - <array> - {{range .Exec -}} - <string>{{.}}</string> - {{end}} - </array> - <key>RunAtLoad</key> - <true/> - </dict> -</plist>` - -var launchDir string - -func init() { - launchDir = filepath.Join(os.Getenv("HOME"), "Library", "LaunchAgents") -} - -func (a *App) path() string { - return filepath.Join(launchDir, a.Name+".plist") -} - -// IsEnabled Check is app enabled startup. -func (a *App) IsEnabled() bool { - _, err := os.Stat(a.path()) - return err == nil -} - -// Enable this app on startup. -func (a *App) Enable() error { - t := template.Must(template.New("job").Parse(jobTemplate)) - - if err := os.MkdirAll(launchDir, 0777); err != nil { - return err - } - f, err := os.Create(a.path()) - if err != nil { - return err - } - defer f.Close() - - if err := t.Execute(f, a); err != nil { - return err - } - - return nil -} - -// Disable this app on startup. -func (a *App) Disable() error { - - return os.Remove(a.path()) -} |