chromium

package
v0.71.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: AGPL-3.0 Imports: 13 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 chromium launches the app window: lich's own Chromium (CEF, built out of shell/), pointed at the loopback listener that serves the frontend and the RPC/terminal transports (docs/chromium-shell.md).

Index

Constants

View Source
const NoWindowArg = "--no-window"

NoWindowArg starts lich without its window.

View Source
const OverrideEnv = "LICH_SHELL"

OverrideEnv pins the window to launch, by path. The --shell flag is carried in it rather than passed down as an argument, so the restart successor inherits the choice and `lich doctor` reports the window a launch here would actually open. `task dev` is the one caller: `go run` has no window beside its binary.

View Source
const TabFallback = false

TabFallback is macOS's alone (fallback_darwin.go): here a missing or dying window is the error the user sees.

Variables

View Source
var ErrNoShell = errors.New(
	"no window beside the lich binary: lich-shell is missing. Every release is a complete package, " +
		"the binary and its shell folder together; install one from " +
		"https://github.com/lichdotdev/lich/releases/latest, or point LICH_SHELL at a window build")

ErrNoShell is an install with no window of its own: nothing at shellPaths and no pin. It is a sentinel because the caller answers it differently from every other failure: on macOS lich still runs, in a plain tab of the default browser (main.go's openTab), while everywhere else it is the error the user has to see: a package missing its window, or a binary copied out of the package it shipped in.

Functions

func Args

func Args(url, dataDir, class string, extra []string) []string

Args builds the window's argv; shell/src/main.rs is the other side of the contract. The dedicated user-data-dir is load-bearing: the profile holds the frontend's localStorage (lich.* settings), so it must persist across runs. class is the WM_CLASS: the dev shell passes its own so compositor window rules targeting the daily driver never capture the dev window.

func Focus

func Focus(url, dataDir, class string) error

Focus hands url to the window a running lich has open and waits for the hand-off to end. The process is a second instance that Chromium's profile lock forwards to the first, and its exit is not a window failing to open — CEF reports the forward as a failed initialise, so the duplicate exits 1 by design.

func ParseFlags

func ParseFlags(args []string) (pinned string, noWindow bool, extra []string)

ParseFlags splits lich's own launch arguments: --shell <path> pins the window to open, --no-window starts the backend without one (`lich native` uses it), and everything after `--` passes through to the window as Chromium switches. The --shell flag wins over its environment variable because the caller writes it into the environment (main.go), which is also what carries it to the restart successor.

func RelaunchArgs

func RelaunchArgs(extra []string) []string

RelaunchArgs are the arguments that launch lich again with the window switches extra came from: ParseFlags' inverse for them, nil for none. The --shell pin is not among them; it rides the environment (main.go).

func Run

func Run(url, dataDir, class string, extra []string, onStart func(close func() error)) error

Run opens the window and blocks until it closes. The backend outlives it: the caller decides what the end means (EndingOf). ErrNoShell comes back untouched, because the answer to an install with no window is not this function's to give. Extra args pass through to Chromium (e.g. --ozone-platform=wayland). onStart, when non-nil, receives a func that closes the window once it is launched, before the blocking wait: lich's own close, for quitting and restarting, which the page is not asked about (a close the user makes is).

func Why

func Why(err error) string

Why is err short enough for a dialog: an ExitError keeps only the lines that say why, its FATAL lines when it has any and its last lines otherwise.

Types

type Ending

type Ending int

Ending is what a window that has ended means for the lich behind it. The backend outlives its window, so most endings leave it serving; only a launch that never put a window on screen has nobody to serve.

const (
	// WindowClosed: the user closed it. The sessions keep running and the next
	// launch of lich opens a window on them.
	WindowClosed Ending = iota
	// WindowTabInstead: macOS's last rung (TabFallback). There is no window of
	// lich's own here, so the page opens in the default browser.
	WindowTabInstead
	// WindowFailed: the window died with an error, after this lich already had
	// one on screen or after its startup. Report it and keep serving: the
	// sessions behind it are alive and the next launch opens a window on them.
	WindowFailed
	// WindowNeverOpened: this launch's first window failed to come up. Report it
	// and exit, as a launch that shows nothing must not leave a lich nobody can
	// see holding the port.
	WindowNeverOpened
)

func EndingOf

func EndingOf(err error, first bool, uptime time.Duration) Ending

EndingOf reads a window's end: err is what Run returned, first is whether it was the first window this lich opened, uptime how long it ran.

type Env

type Env struct {
	LookPath func(name string) (string, error)
	Getenv   func(key string) string
	// Shell is the path of the window this install bundles, "" when it has
	// none (shell.go).
	Shell func() string
}

Env is everything resolution reads from the machine. Every probe is a field so the ladder is table-testable on a machine with no window built.

func RealEnv

func RealEnv() Env

RealEnv reaches the machine lich is running on.

type ExitError

type ExitError struct {
	Err    error
	Stderr []string
}

ExitError is the window exiting with an error, with the end of what it wrote to stderr: a launcher start has no terminal, so without it the log holds the signal the window died of and never the reason.

func (*ExitError) Error

func (e *ExitError) Error() string

func (*ExitError) Unwrap

func (e *ExitError) Unwrap() error

type Result

type Result struct {
	// Path is the executable to run.
	Path string
	// Step names the rung that answered, for `lich doctor` and `lich rage`.
	Step string
}

Result is a resolved launch: which executable, and which rung named it.

func Resolve

func Resolve(env Env) (Result, error)

Resolve finds the window: the one the user pinned, else the one lich itself bundles. It returns ErrNoShell when the install has neither — see that variable for what the caller makes of it.

func (Result) Describe

func (r Result) Describe() string

Describe is the resolution as a diagnostic prints it: the command, and the rung that produced it.

func (Result) ProfileDir

func (r Result) ProfileDir(dir string) string

ProfileDir is where this window's profile goes, given the directory lich would use: one keyed subdirectory per window. A Chromium profile is a particular build's own state, so handing one build's to another is a silent adoption at best, and at worst a window that refuses to start on a profile a newer one wrote.

Jump to

Keyboard shortcuts

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