From b3084c0ab60b375a489c1641e551c86dc6cf9916 Mon Sep 17 00:00:00 2001 From: Quentin Laffont Date: Wed, 17 Jun 2026 09:36:47 +0200 Subject: [PATCH 1/2] Add bettercapture:// URL scheme for external automation Register a custom URL scheme so tools like Raycast and Shortcuts can toggle recording and open the output folder without keyboard relay. Closes discussion: https://github.com/jsattler/BetterCapture/discussions/169 Co-authored-by: Cursor --- BetterCapture/BetterCaptureApp.swift | 30 ++++++++++++++++++++++++++++ BetterCapture/Info.plist | 11 ++++++++++ README.md | 15 ++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/BetterCapture/BetterCaptureApp.swift b/BetterCapture/BetterCaptureApp.swift index c2826a3..122bb98 100644 --- a/BetterCapture/BetterCaptureApp.swift +++ b/BetterCapture/BetterCaptureApp.swift @@ -5,6 +5,7 @@ // Created by Joshua Sattler on 29.01.26. // +import AppKit import KeyboardShortcuts import SwiftUI @@ -21,6 +22,9 @@ struct BetterCaptureApp: App { await viewModel.requestPermissionsOnLaunch() registerKeyboardShortcuts() } + .onOpenURL { url in + handleURL(url) + } } label: { MenuBarLabel(viewModel: viewModel) } @@ -32,6 +36,32 @@ struct BetterCaptureApp: App { } } + // MARK: - URL Scheme + + private func handleURL(_ url: URL) { + guard url.scheme == "bettercapture" else { return } + + switch url.host { + case "toggle": + Task { @MainActor in + await viewModel.toggleRecording() + } + case "open-recordings": + Task { @MainActor in + let settings = viewModel.settings + let didStart = settings.startAccessingOutputDirectory() + defer { + if didStart { + settings.stopAccessingOutputDirectory() + } + } + NSWorkspace.shared.selectFile(nil, inFileViewerRootedAtPath: settings.outputDirectory.path) + } + default: + break + } + } + // MARK: - Keyboard Shortcuts private func registerKeyboardShortcuts() { diff --git a/BetterCapture/Info.plist b/BetterCapture/Info.plist index aaff686..a3edc32 100644 --- a/BetterCapture/Info.plist +++ b/BetterCapture/Info.plist @@ -16,5 +16,16 @@ SPARKLE_PUBLIC_KEY SUEnableInstallerLauncherService + CFBundleURLTypes + + + CFBundleURLName + com.sattlerjoshua.BetterCapture + CFBundleURLSchemes + + bettercapture + + + diff --git a/README.md b/README.md index 56b091f..0c0b6bb 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,21 @@ Download the latest release from [GitHub Releases](https://github.com/jsattler/B **Requirements**: macOS 15.2 (Sequoia) or later +## Automation + +BetterCapture supports a custom URL scheme for external tools (Raycast, Shortcuts, Alfred): + +| URL | Action | +|---|---| +| `bettercapture://toggle` | Toggle recording (same as the Toggle Recording shortcut) | +| `bettercapture://open-recordings` | Open the output folder in Finder | + +Example: + +```bash +open "bettercapture://toggle" +``` + ## Contributing We welcome contributions of all kinds! Please see our [Contributing Guidelines](CONTRIBUTING.md) for more details on how to get involved. From 3bc8f2b239d79669e62681a3f03857cfee94c698 Mon Sep 17 00:00:00 2001 From: Quentin Laffont Date: Wed, 17 Jun 2026 09:42:29 +0200 Subject: [PATCH 2/2] fix: toggle URL stops recording or opens content selection When idle, bettercapture://toggle now opens Pick Content or Select Area instead of auto-starting with a previously selected source. Co-authored-by: Cursor --- BetterCapture/BetterCaptureApp.swift | 11 ++++++++++- README.md | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/BetterCapture/BetterCaptureApp.swift b/BetterCapture/BetterCaptureApp.swift index 122bb98..1d2cc1c 100644 --- a/BetterCapture/BetterCaptureApp.swift +++ b/BetterCapture/BetterCaptureApp.swift @@ -44,7 +44,16 @@ struct BetterCaptureApp: App { switch url.host { case "toggle": Task { @MainActor in - await viewModel.toggleRecording() + if viewModel.isRecording { + await viewModel.stopRecording() + } else { + switch ContentSelectionMode.current { + case .pickContent: + viewModel.presentPicker() + case .selectArea: + await viewModel.presentAreaSelection() + } + } } case "open-recordings": Task { @MainActor in diff --git a/README.md b/README.md index 0c0b6bb..d16084f 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ BetterCapture supports a custom URL scheme for external tools (Raycast, Shortcut | URL | Action | |---|---| -| `bettercapture://toggle` | Toggle recording (same as the Toggle Recording shortcut) | +| `bettercapture://toggle` | Stop recording if active; otherwise open content selection (Pick Content or Select Area) before recording | | `bettercapture://open-recordings` | Open the output folder in Finder | Example: