Documentation
¶
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 ¶
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.
var ErrNoBrowser = errors.New("no Chrome, Edge, Brave or Chromium on this Mac")
ErrNoBrowser: none of the Candidates is installed.
Functions ¶
func FindBrowser ¶
FindBrowser returns the executable of the first installed Candidate.
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.