Repository navigation
feat(cli): add bettercapture command-line tool - #238
Merged
jsattler merged 6 commits intoNov 20, 2026
Merged
Conversation
Migrate preferences from the sandbox container on first launch so settings, shortcuts and the output folder survive the switch. Refs #237
Serve one JSON request per connection on a per-user Unix socket so the command-line tool can list targets and start, pause, stop and wait for recordings without the picker. Gated behind a new, off by default Command Line setting. Refs #237
Ship the tool in Contents/Helpers, link it into ~/.local/bin on launch, show in Settings whether the login shell finds it, and add skill show for agents. Keep a running instance's socket when a second copy, such as the test host, starts. Refs #237
Debug builds skipped the ~/.local/bin link, and Settings then told users to fix a PATH that was already correct. Link in every build and report a link blocked by another file separately from a missing PATH. Refs #237
Recordings started in the same second shared a file name, and setting up the writer deletes an existing file at that URL.
Each command-line recording is now a separate session with an ID, an optional name and metadata, so several can run at once. stop, pause, resume, wait and status take an ID or name; stop --all stops every recording.
jsattler
force-pushed
the
237-add-command-line-interface-for-automation-and-agents
branch
from
November 20, 2026 19:19
3833b39 to
649b8f7
Compare
jsattler
deleted the
237-add-command-line-interface-for-automation-and-agents
branch
November 20, 2026 19:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #237
Summary
Adds a
bettercapturecommand so scripts and AI agents can list capture targets, start and stop recordings without the picker, and get the saved file's path back as JSON.The running app is the server. The CLI is a thin client that sends one JSON request per connection over a Unix socket. The app keeps owning the Screen Recording permission, so terminals and agents never need it. CLI and menu bar act on the same
RecorderViewModel, so either can stop a recording the other started.bettercapture apps bettercapture record --app com.apple.Safari --duration 30s --wait --json bettercapture record --area 0,0,1280,720 bettercapture stop bettercapture skill show # usage guide for AI agentsChanges
Remove the App Sandbox (
e1c29f2)SUEnableInstallerLauncherService, which Sparkle only uses for sandboxed apps.SandboxPreferencesMigrationcopies the container's preferences into~/Library/Preferencesonce, at launch. That keeps settings, keyboard shortcuts, Sparkle preferences and the output folder bookmark.Control server in the app (
d68060d)<per-user temp dir>/<bundle id>.sock, with mode0600. If another copy of the app is already answering on it, the server leaves it alone.mainor name), a window (ID or title), an app (bundle ID or name), or an area of a display. Each matches the exact ID, then the exact name ignoring case, then part of a name. More than one match is an error that lists the candidates.durationSecondsis handled by the app, so a timed recording stops even if the CLI exits.CLI tool (
305a7cc)BetterCaptureCLItarget, built withswift-argument-parserand embedded atBetterCapture.app/Contents/Helpers/bettercapture.--jsonon every command. Exit codes: 0 ok, 1 failure, 2 usage, 3 target not found or ambiguous, 4 app unreachable, 5 disabled or permission missing.record --wait, Ctrl-C stops and saves the recording.~/.local/bin/bettercaptureat every launch, without editing dotfiles. Whichever build launched last owns the link. Settings shows whether the login shell finds the command, and either the PATH line to add or that another file is in the way.skill showprints a guide for AI agents, including the tool's full path as a fallback.--generate-completion-script.Changes from the issue
--display 2were dropped, since display IDs are small numbers too.--pickand the per-recording options (--codec,--fps, …) are left for a follow-up.recordwithout a target records the main display.Testing
--durationand--wait, Ctrl-C during--wait, pause and resume, the disabled state, not-found and ambiguous targets, and invalid arguments.Still to check on a prerelease build:
~/.local/bin/bettercapturegets createdAfter release: add
binary "#{appdir}/BetterCapture.app/Contents/Helpers/bettercapture"to the Homebrew cask.