Documentation
¶
Overview ¶
Package loginitem starts the Blitz service (blitzd) at login and controls it: a launchd agent on macOS, a systemd user unit on Linux. On Windows only the tray starts at login (InstallTray), and it starts the service. The CLI (`blitz service …`) and the desktop app both use it, so the app needs no CLI to install, restart or stop the service.
Index ¶
- Constants
- Variables
- func Beside() string
- func FindService(dirs ...string) (string, error)
- func Install(blitzd string) error
- func InstallTray(bin string) error
- func Installed() bool
- func LogFile() string
- func Path() (string, error)
- func Restart() error
- func RunfilesRoots() []string
- func ServiceDirs() []string
- func Start() error
- func Stop() error
- func TrayInstalled() bool
- func TrayPath() (string, error)
- func Uninstall() error
- func UninstallTray() error
Constants ¶
const ( // Label is the launchd agent's label (macOS). Label = "dev.blitz.service" // Unit is the systemd user unit (Linux). Unit = "blitz.service" )
const TrayLabel = "dev.blitz.tray"
TrayLabel is the tray's launchd agent (macOS); on Linux the tray starts from an XDG autostart entry, as graphical programs do, and on Windows from a value in the registry's Run key.
Variables ¶
var ErrNotInstalled = errors.New("the Blitz service isn't installed to start at login")
ErrNotInstalled means the login item isn't installed, and starting or restarting needs it.
var ErrUnsupported = fmt.Errorf("starting the service at login isn't supported on %s: run blitzd yourself", goruntime.GOOS)
ErrUnsupported means login items aren't available: they exist only on macOS and Linux.
var RunSystem = func(name string, args ...string) error { out, err := exec.Command(name, args...).CombinedOutput() if err != nil { return fmt.Errorf("%s %s: %w: %s", name, strings.Join(args, " "), err, strings.TrimSpace(string(out))) } return nil }
RunSystem runs a system command (launchctl, systemctl); tests replace it.
Functions ¶
func Beside ¶
func Beside() string
Beside is the directory of the running program (symlinks resolved), for FindService.
func FindService ¶
FindService finds blitzd: in dirs (beside the program asking, as released and bundled), else on PATH. The result has symlinks resolved, so a login item keeps working when the link moves.
func Install ¶
Install writes the login item for blitzd (an absolute path) and starts it now, replacing a previous item and stopping the service it ran.
func InstallTray ¶
InstallTray makes bin (blitz-tray, an absolute path) start at login. On macOS launchd starts it now too; on Linux and Windows the caller starts it.
func LogFile ¶
func LogFile() string
LogFile is where the service's output goes on macOS (systemd keeps it in the journal on Linux).
func Restart ¶
func Restart() error
Restart stops the service the login item runs, if it runs, and starts it again.
func RunfilesRoots ¶ added in v0.3.1
func RunfilesRoots() []string
RunfilesRoots are where Bazel puts the running program's runfiles, when Bazel runs it (bazel run, bazel test).
func ServiceDirs ¶ added in v0.3.1
func ServiceDirs() []string
ServiceDirs are where a program finds the blitzd that goes with it: beside it (as released and bundled), then in its Bazel runfiles.
func Stop ¶
func Stop() error
Stop stops the service the login item runs, until the next login (or Start, or Install).
func TrayInstalled ¶
func TrayInstalled() bool
TrayInstalled reports whether the tray starts at login.
func Uninstall ¶
func Uninstall() error
Uninstall stops the service the login item runs and removes the item.
func UninstallTray ¶
func UninstallTray() error
UninstallTray stops the tray starting at login (and on macOS, stops it).
Types ¶
This section is empty.