JSON output and exit codes

Machine-readable output and the exit codes the glimmer command returns, for scripts and CI.

JSON#

Add --json (or -j) to any command. Success is one JSON object on standard output; an error is one JSON object on standard error. watch prints one object per line.

{
  "schemaVersion": 1,
  "ok": true,
  "command": "capture",
  "result": {
    "format": "png", "byteCount": 401233, "pixelWidth": 2560, "pixelHeight": 1600, "scale": 2,
    "target": { "kind": "window", "matchCount": 2 },
    "redaction": { "status": "applied", "regions": 1 },
    "notices": [], "library": null
  },
  "output": { "path": "/Users/you/safari.png" }
}
{
  "schemaVersion": 1,
  "ok": false,
  "command": "capture",
  "error": {
    "code": "no-match.window", "message": "No window matches bundle ID com.example.none.",
    "hint": "Run `glimmer windows` to see what can be captured.",
    "exitCode": 4, "exitName": "no-match", "retryable": false
  }
}

--json can’t be combined with image bytes on standard output; use -o FILE.

What’s in result#

CommandFields
capture, cardformat, byteCount, pixelWidth, pixelHeight, scale, target, redaction, notices, library
ocr, grab-texttext, lines[] (text, confidence, bounds), codes[], level, languages, target, redaction
windowsa list of index, id, bundleID, app, title, frame, layer, onScreen, captureProtected
displaysa list of index, id, uuid, name, frame, scale, pixelWidth, pixelHeight, primary, rotation
destinationswherry (ready, not-installed, needs-consent…), destinations[] (id, name, kind, available)
uploaduploadID, destination, remoteKey, link, verified
pipelines, runthe workflow list; for run: name, status, outputs[]
diffchangedPixels, comparedPixels, changedPercent, thresholdPercent, exceeded, width, height, sizeMismatch, hasDiffImage, baseline, candidate
watch (per line)event: sequence, timestamp, changedPercent, changedRect, captureID
versioncli (version, protocol, jsonSchema), app, appError

Keys are camelCase and dates are ISO 8601. Within a schema version, fields are never removed, renamed or retyped; new ones may appear, so ignore keys you don’t know.

Exit codes#

Exit codes never change meaning.

CodeNameMeaning
0success
1failureAnything not listed below
2usageBad arguments, a terminal where a pipe is needed, unreadable input
3permission-deniedGlimmer lacks Screen Recording or Accessibility, or you declined this client
4no-matchNo window, display, destination or workflow matches
5cancelledYou cancelled (Esc in the overlay, Cancel in a confirmation)
6timeout--timeout passed
7diff-exceededdiff changed more than --threshold
8upload-failedThe upload failed or its link couldn’t be checked
9no-gui-sessionNo logged-in session with a screen (SSH, launchd daemon, headless CI), or the screen is locked
10version-mismatchThe command and the app are different versions; the message says which to update
11app-unavailableGlimmer isn’t installed, isn’t running with --no-launch, or didn’t start in time
12busyGlimmer is in the middle of another capture or recording
13no-textNo text found (see --allow-empty)
14redaction-requiredSomething needs a person to review it before these pixels can leave
15unavailableNot available in this version, or not set up
16capture-failedThe capture produced nothing (a protected or vanished window, a blank frame)
17storageSaving failed (disk full, folder missing, -o not writable)
130interruptedCtrl-C
143terminatedSIGTERM

Next#

Something missing or unclear? Write to [email protected].

↑ ↓ to move, Enter to open, Esc to close