macengine

package
v0.4.12 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Rendered for darwin/amd64

Overview

Package macengine finds the Chromium-family browser on a Mac and makes the copy of it an app runs on: the app's name, id and icon in its Info.plist, so to macOS the running browser is the app (its Dock icon, ⌘Tab entry, menu bar, notifications), and its --app windows have a bare title bar.

Why a copy: what the Dock, ⌘Tab and the menu bar show for a process comes from its bundle's Info.plist, and macOS lets a process change only its own type (lsappinfo setinfo on another one is ignored). Run as installed, the browser is "Google Chrome": a second Chrome icon in the Dock, Chrome's name in the menu bar.

  • APFS clone (cp -c): about a second, and no disk space while it shares blocks with the original. One framework version (~700MB) becomes the copy's own once the browser updates past it, so only the running version is kept, and the copy is made again when the browser's version (or the app's brand) changes, older copies deleted.
  • Name, id and icon, nothing else. LSUIElement breaks Chromium: it reads it to decide it is a helper process and then can't find its framework ("icudtl.dat not found in bundle", from the second launch on, once LaunchServices registered the bundle). Symlinking the browser's binary or Frameworks into a bundle of ours fails the same way.
  • The icon lives in Assets.car too (CFBundleIconName), which macOS prefers to the .icns: that key goes.
  • Editing the plist breaks the vendor's signature (SIGKILL at launch): the copy is re-signed ad hoc, after stripping extended attributes (codesign refuses "detritus"). The nested framework keeps the vendor's signature. Ad hoc also means no hardened runtime and no library validation: the app's menu library can load.
  • A re-signed copy is another code identity: the user's keychain items for the browser would prompt, so the engine runs with --use-mock-keychain.
  • The Dock shows the bundle's folder name, not CFBundleName: the copy is <dir>/<browser version>/<Name>.app.
  • The first launch of a fresh copy takes ~10s (macOS scanning the newly signed bundle), once per browser version.

Index

Constants

This section is empty.

Variables

View Source
var Candidates = []string{"Google Chrome", "Microsoft Edge", "Brave Browser", "Chromium"}

Candidates are the browsers looked for, in order. Each is "<name>.app" in /Applications or ~/Applications.

View Source
var ErrNoBrowser = errors.New("no Chrome, Edge, Brave or Chromium on this Mac")

ErrNoBrowser: none of the Candidates is installed.

Functions

func App

func App(exe string) string

App is the .app bundle an engine executable is in.

func FindBrowser

func FindBrowser() (string, error)

FindBrowser returns the executable of the first installed Candidate.

func Prepare

func Prepare(exe, dir string, b Brand, logf func(string, ...any)) (string, error)

Prepare returns the executable of a copy of the browser at exe carrying b, making it in dir if needed.

Types

type Brand

type Brand struct {
	Name string // Dock, ⌘Tab, menu bar, notifications
	ID   string // CFBundleIdentifier: its own, so its notification permission and Dock place aren't the browser's
	// Schemes replace the browser's URL types (http, https, file…): the copy is the handler of the app's own schemes
	// only. LaunchServices then sends their links to the copy: running, the menu library takes them; not running, it
	// is started by LaunchServices itself, with Env.
	Schemes []string
	// Env is the copy's LSEnvironment (with the browser's own): what a launch by LaunchServices (a link, not the
	// shell) gets, e.g. the menu library to load.
	Env  map[string]string
	ICNS []byte // the icon; nil = keep the browser's
}

Brand is what the copy is to macOS.

Jump to

Keyboard shortcuts

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