Documentation
¶
Overview ¶
Package tray is the Blitz tray icon's behaviour, apart from the icon library: what the service's state is, the menu for it, and what its items do. cmd blitz-tray draws it with fyne.io/systray.
Index ¶
- func Detached(name string, args ...string) error
- func ICO(pngData []byte) ([]byte, error)
- func Language(b *i18n.Bundle, prefs []byte, system []string) language.Tag
- func LogDir() string
- func ServiceLogDir(ctx context.Context, sock string) string
- func SetupLocale()
- func Shutdown(ctx context.Context, sock string) error
- func SystemLanguages() []string
- type Actions
- type Host
- type Item
- type Menu
- type ServiceStatus
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Detached ¶
Detached starts a program in its own session, with no terminal and its output discarded, and reaps it when it exits.
func ICO ¶ added in v0.4.0
ICO wraps a PNG in an icon file (.ico), which Windows wants for a tray icon: one image, stored as the PNG itself, as Windows Vista and later read it.
func Language ¶
Language is the language the tray shows: the desktop app's setting (prefs, the content of ~/.blitz/desktop.json) unless it's "system"; else the first of the system's languages (most preferred first) with a catalog; else English. It chooses as the app's window does.
func LogDir ¶
func LogDir() string
LogDir is where the service's logs go by the settings file: log.dir of the global settings.
func ServiceLogDir ¶
ServiceLogDir is where the service at sock writes its log, as it says (ListLogDays): the log.dir it started with. "" when it isn't running, doesn't say, or has its log off.
func SetupLocale ¶
func SetupLocale()
SetupLocale shows the tray in the desktop app's language (Settings › Language), from the same catalogs, with ui.locales_dir's added.
func Shutdown ¶ added in v0.4.0
Shutdown asks the service at sock to stop (WorkspaceService.Shutdown): how the tray stops one it can't signal (Windows).
func SystemLanguages ¶
func SystemLanguages() []string
SystemLanguages are the user's languages, most preferred first: macOS's list (programs started at login have no LANG there), then LANGUAGE, LC_ALL, LC_MESSAGES and LANG.
Types ¶
type Actions ¶
type Actions struct {
// Run starts a program and doesn't wait for it.
Run func(name string, args ...string) error
// Beside is the tray's own directory (blitzd and the app are there
// when installed together).
Beside string
// Status is the service's state now.
Status func() Status
// Wait polls until the service is (or isn't) running, for up to d.
Wait func(running bool, d time.Duration) bool
// LogDir is where the running service says its log is ("" when it
// doesn't say); nil asks nobody. The settings file answers otherwise.
LogDir func() string
// Shutdown asks the service to stop (nil: nobody is asked, and Stop
// signals it).
Shutdown func() error
// Page is a link that opens the page the tray serves (Windows, which
// has no desktop app); nil opens the desktop app instead.
Page func() (string, error)
}
Actions are what the menu's items do. Each has what it needs to find and run the system's programs; tests replace them.
func (Actions) OpenApp ¶
OpenApp opens the desktop app: the bundle the tray is in (macOS), blitz-desktop beside it or on PATH (Linux); or, with a Page, the page in a browser's app window (Windows).
func (Actions) OpenLogs ¶
OpenLogs shows the logs folder in the file manager: the running service's, which may not be the settings file's (another --config, or log.dir changed since it started).
type Host ¶ added in v0.4.0
type Host struct {
Actions Actions
// Version is the tray's, which the page shows as the app's.
Version string
// Socket is the service's.
Socket string
// Tray is the tray's own program, which starts at login.
Tray string
}
Host answers the page the tray serves (pageserver.HostPrefix) with what the desktop app's bindings do and a browser can't: the service's status and controls, starting at login, showing files, the licenses. The page calls POST /host/<Method> with its arguments as a JSON array and gets the result as JSON, or {"error": "…"} with status 500, the method names being the desktop app's (window.go.main.App); GET /host/info lists them.
type Menu ¶
type Menu struct {
Running bool // which icon
Tooltip string
// State is the first line: what the service is doing (not clickable).
State Item
Start, Stop, Restart Item
}
Menu is what the tray shows for a status.
type ServiceStatus ¶ added in v0.4.0
type ServiceStatus struct {
Running bool `json:"running"`
Installed bool `json:"installed"`
Socket string `json:"socket"`
Service string `json:"service"`
Tray string `json:"tray"`
TrayInstalled bool `json:"tray_installed"`
}
ServiceStatus is the desktop app's ServiceStatus, as the page reads it.
type Status ¶
type Status struct {
// Running means the service answers on its socket.
Running bool
// Installed means it starts at login (a launchd agent or systemd unit).
Installed bool
// Version and PID are what the running service says (GetServiceInfo).
Version string
PID int
}
Status is the service as the tray sees it.