appwindow

package
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const BrowserEnv = "FLOCKDECK_BROWSER"

BrowserEnv names the browser to use, overriding the search: a path, a program on PATH, or one of browserNames.

Variables

View Source
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.

View Source
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

func OpenDefault(url string) error

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

func Open(url, profileDir string) (*Window, error)

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

func (w *Window) Wait() error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL