Documentation
¶
Overview ¶
Package appwindow opens the user interface in its own window.
A Chromium-based browser in "app mode" gives a chromeless window with no tabs, address bar or bookmarks, which reads as a native application window while keeping the whole program a single dependency-free binary. If no such browser is available the page is opened in the default browser instead.
Index ¶
Constants ¶
const BrowserEnv = "FLOCKDECK_BROWSER"
BrowserEnv names the browser to use, overriding the search: a path, a program on PATH, or one of browserNames.
Variables ¶
var ErrHandedOff = errors.New("the window was handed to a browser already running")
ErrHandedOff is returned by Wait when the browser gave the window to a process of its own that was already running, and exited. The window is open, but nothing here can tell when it closes.
var ErrNoBrowser = errors.New("no browser found to display the interface")
ErrNoBrowser is returned when nothing could be found to display the UI.
Functions ¶
func OpenDefault ¶ added in v0.3.3
OpenDefault opens url in the user's default browser, as Open does when no app-mode browser will start. The tab it opens cannot be watched.
Types ¶
type StartError ¶ added in v0.3.3
type StartError struct {
// Program is the browser that was started, and Code what it exited with.
Program string
Code int
// Stderr is the last few lines the browser printed, which is where it
// says why.
Stderr string
}
StartError is returned by Wait when the browser failed so soon after it was started that its window cannot have opened: on Linux with no display to open it on, say, or a snap-packaged Chromium refused its profile folder.
func (*StartError) Error ¶ added in v0.3.3
func (e *StartError) Error() string
type Window ¶
type Window struct {
// AppMode reports whether the window is a dedicated app window rather than
// a tab in the user's ordinary browser.
AppMode bool
// Program is the browser that was launched, for diagnostics.
Program string
// contains filtered or unexported fields
}
Window is a running UI window.
func Open ¶
Open displays url in a window. profileDir holds the browser profile used for app mode, keeping it separate from the user's own browsing profile so the window opens clean and does not disturb their session.
func (*Window) Close ¶
func (w *Window) Close()
Close closes an app-mode window.
The browser is asked first, with SIGTERM, which Chromium takes as being told to close: it saves the window's size and place as it goes, which is what the next window opens at (see placementArgs). Killed outright, as it always was, it saved nothing, and could count the run as a crash. Only one that has not gone after closeGrace is killed. A Windows process cannot be sent SIGTERM, so there it is killed, as before.
func (*Window) Wait ¶
Wait blocks until an app-mode window is closed. It returns immediately for a tab opened in the default browser, whose lifetime cannot be observed, returns ErrHandedOff for a window another browser process took over, and a *StartError for a browser that failed before its window could have opened.
Such a browser used to come back as its own exit status, which reads the same as the window being closed, and the application stopped with it -- at once, and without a word, since what the browser had said went nowhere.