Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions BetterCapture/BetterCaptureApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by Joshua Sattler on 29.01.26.
//

import AppKit
import KeyboardShortcuts
import SwiftUI

Expand All @@ -21,6 +22,9 @@ struct BetterCaptureApp: App {
await viewModel.requestPermissionsOnLaunch()
registerKeyboardShortcuts()
}
.onOpenURL { url in
handleURL(url)
}
} label: {
MenuBarLabel(viewModel: viewModel)
}
Expand All @@ -32,6 +36,41 @@ 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
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
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() {
Expand Down
11 changes: 11 additions & 0 deletions BetterCapture/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,16 @@
<string>SPARKLE_PUBLIC_KEY</string>
<key>SUEnableInstallerLauncherService</key>
<true/>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.sattlerjoshua.BetterCapture</string>
<key>CFBundleURLSchemes</key>
<array>
<string>bettercapture</string>
</array>
</dict>
</array>
</dict>
</plist>
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` | 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:

```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.
Expand Down
Loading