-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: add recording control deeplinks and Raycast extension #1587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
buildingvibes
wants to merge
7
commits into
CapSoftware:main
Choose a base branch
from
buildingvibes:fix/deeplinks-and-raycast
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8e6e4c9
feat: add recording control deeplinks and Raycast extension (#1540)
buildingvibes 5ed09bb
fix: address review feedback for Raycast extension
buildingvibes 10d4a01
fix: address PR review comments for deeplinks and Raycast extension
buildingvibes 9155c00
fix: address round 2 review feedback for Raycast extension
buildingvibes 3d8de3e
fix: remove misleading fallback values in Raycast display/camera lists
buildingvibes 80eb49a
fix: remove hardcoded mic fallback in Raycast extension
buildingvibes 5bcb882
fix: address remaining review feedback
buildingvibes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| node_modules/ | ||
| .raycast/ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| { | ||
| "$schema": "https://www.raycast.com/schemas/extension.json", | ||
| "name": "cap", | ||
| "title": "Cap", | ||
| "description": "Control Cap screen recorder via deeplinks - start, stop, pause, resume recording, switch camera/microphone, and take screenshots.", | ||
| "icon": "command-icon.png", | ||
| "author": "cap", | ||
| "categories": ["Productivity", "Applications"], | ||
| "license": "AGPL-3.0-or-later", | ||
| "commands": [ | ||
| { | ||
| "name": "start-recording", | ||
| "title": "Start Recording", | ||
| "subtitle": "Cap", | ||
| "description": "Start a new screen recording in Cap", | ||
| "mode": "view" | ||
| }, | ||
| { | ||
| "name": "stop-recording", | ||
| "title": "Stop Recording", | ||
| "subtitle": "Cap", | ||
| "description": "Stop the current recording in Cap", | ||
| "mode": "no-view" | ||
| }, | ||
| { | ||
| "name": "pause-recording", | ||
| "title": "Pause Recording", | ||
| "subtitle": "Cap", | ||
| "description": "Pause the current recording in Cap", | ||
| "mode": "no-view" | ||
| }, | ||
| { | ||
| "name": "resume-recording", | ||
| "title": "Resume Recording", | ||
| "subtitle": "Cap", | ||
| "description": "Resume a paused recording in Cap", | ||
| "mode": "no-view" | ||
| }, | ||
| { | ||
| "name": "toggle-pause-recording", | ||
| "title": "Toggle Pause Recording", | ||
| "subtitle": "Cap", | ||
| "description": "Toggle pause/resume on the current recording in Cap", | ||
| "mode": "no-view" | ||
| }, | ||
| { | ||
| "name": "switch-microphone", | ||
| "title": "Switch Microphone", | ||
| "subtitle": "Cap", | ||
| "description": "Switch the active microphone in Cap", | ||
| "mode": "view" | ||
| }, | ||
| { | ||
| "name": "switch-camera", | ||
| "title": "Switch Camera", | ||
| "subtitle": "Cap", | ||
| "description": "Switch the active camera in Cap", | ||
| "mode": "view" | ||
| }, | ||
| { | ||
| "name": "take-screenshot", | ||
| "title": "Take Screenshot", | ||
| "subtitle": "Cap", | ||
| "description": "Take a screenshot with Cap", | ||
| "mode": "view" | ||
| }, | ||
| { | ||
| "name": "open-settings", | ||
| "title": "Open Settings", | ||
| "subtitle": "Cap", | ||
| "description": "Open Cap settings", | ||
| "mode": "no-view" | ||
| } | ||
| ], | ||
| "dependencies": { | ||
| "@raycast/api": "^1.93.2", | ||
| "@raycast/utils": "^1.19.1" | ||
| }, | ||
| "devDependencies": { | ||
| "@raycast/eslint-config": "^1.0.11", | ||
| "@types/node": "22.13.1", | ||
| "@types/react": "19.0.8", | ||
| "eslint": "^9.18.0", | ||
| "prettier": "^3.4.2", | ||
| "typescript": "^5.7.3" | ||
| }, | ||
| "scripts": { | ||
| "build": "ray build", | ||
| "dev": "ray develop", | ||
| "fix-lint": "ray lint --fix", | ||
| "lint": "ray lint" | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { executeDeepLink } from "./utils"; | ||
|
|
||
| export default async function OpenSettings() { | ||
| await executeDeepLink( | ||
| { | ||
| open_settings: { | ||
| page: null, | ||
| }, | ||
| }, | ||
buildingvibes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "Opening Cap settings", | ||
| ); | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { executeDeepLink } from "./utils"; | ||
|
|
||
| export default async function PauseRecording() { | ||
| await executeDeepLink("pause_recording", "Pausing recording in Cap"); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { executeDeepLink } from "./utils"; | ||
|
|
||
| export default async function ResumeRecording() { | ||
| await executeDeepLink("resume_recording", "Resuming recording in Cap"); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import { ActionPanel, Action, List } from "@raycast/api"; | ||
| import { useExec } from "@raycast/utils"; | ||
| import { executeDeepLink } from "./utils"; | ||
|
|
||
| function parseDisplays(stdout: string): string[] { | ||
| const displays: string[] = []; | ||
| const lines = stdout.split("\n"); | ||
| for (const line of lines) { | ||
| const match = line.match(/^\s{8}(\S.*):$/); | ||
| if (match && match[1]) { | ||
| displays.push(match[1]); | ||
| } | ||
| } | ||
| return displays; | ||
| } | ||
|
|
||
| async function startRecordingOnDisplay(displayName: string) { | ||
| await executeDeepLink( | ||
| { | ||
| start_recording: { | ||
| capture_mode: { screen: displayName }, | ||
| camera: null, | ||
| mic_label: null, | ||
| capture_system_audio: false, | ||
| mode: "studio", | ||
| }, | ||
| }, | ||
| `Starting recording on "${displayName}" in Cap`, | ||
| ); | ||
| } | ||
|
|
||
| export default function StartRecording() { | ||
| const { data, isLoading } = useExec("system_profiler", ["SPDisplaysDataType", "-detailLevel", "mini"], { | ||
| parseOutput: ({ stdout }) => parseDisplays(stdout), | ||
| }); | ||
|
|
||
| const displays = data ?? []; | ||
|
|
||
| return ( | ||
| <List isLoading={isLoading} searchBarPlaceholder="Select a display to record..."> | ||
| {displays.map((display) => ( | ||
| <List.Item | ||
| key={display} | ||
| title={display} | ||
| actions={ | ||
| <ActionPanel> | ||
| <Action title={`Record ${display}`} onAction={() => startRecordingOnDisplay(display)} /> | ||
| </ActionPanel> | ||
| } | ||
| /> | ||
| ))} | ||
| </List> | ||
| ); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { executeDeepLink } from "./utils"; | ||
|
|
||
| export default async function StopRecording() { | ||
| await executeDeepLink("stop_recording", "Stopping recording in Cap"); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import { Action, ActionPanel, List } from "@raycast/api"; | ||
| import { useExec } from "@raycast/utils"; | ||
| import { executeDeepLink } from "./utils"; | ||
|
|
||
| interface Camera { | ||
| name: string; | ||
| uniqueId: string; | ||
| } | ||
|
|
||
| async function switchCamera(camera: Camera) { | ||
| await executeDeepLink( | ||
| { set_camera: { camera: { DeviceID: camera.uniqueId } } }, | ||
| `Switching camera to "${camera.name}" in Cap`, | ||
| ); | ||
| } | ||
|
|
||
| async function disableCamera() { | ||
| await executeDeepLink( | ||
| { set_camera: { camera: null } }, | ||
| "Disabling camera in Cap", | ||
| ); | ||
| } | ||
|
|
||
| export default function SwitchCamera() { | ||
| const { data, isLoading } = useExec("system_profiler", ["SPCameraDataType", "-detailLevel", "mini"], { | ||
| parseOutput: ({ stdout }) => { | ||
| const cameras: Camera[] = []; | ||
| const lines = stdout.split("\n"); | ||
| let currentName: string | null = null; | ||
| let currentUniqueId: string | null = null; | ||
|
|
||
| for (const line of lines) { | ||
| if (line.match(/^\s{4}\S/) && line.includes(":")) { | ||
| if (currentName && currentUniqueId) { | ||
| cameras.push({ name: currentName, uniqueId: currentUniqueId }); | ||
| } | ||
| const name = line.trim().replace(/:$/, ""); | ||
| if (name.length > 0 && name !== "Camera") { | ||
| currentName = name; | ||
| currentUniqueId = null; | ||
| } else { | ||
| currentName = null; | ||
| currentUniqueId = null; | ||
| } | ||
| } | ||
|
|
||
| const uniqueIdMatch = line.match(/^\s+Unique ID:\s*(.+)/); | ||
| if (uniqueIdMatch && currentName) { | ||
| currentUniqueId = uniqueIdMatch[1].trim(); | ||
| } | ||
| } | ||
|
|
||
| if (currentName && currentUniqueId) { | ||
| cameras.push({ name: currentName, uniqueId: currentUniqueId }); | ||
| } | ||
|
|
||
| return cameras; | ||
| }, | ||
| }); | ||
|
|
||
| const cameras = data ?? []; | ||
|
|
||
| return ( | ||
| <List isLoading={isLoading} searchBarPlaceholder="Search cameras..."> | ||
| <List.Item | ||
| key="disable" | ||
| title="Disable Camera" | ||
| subtitle="Turn off camera input" | ||
| actions={ | ||
| <ActionPanel> | ||
| <Action title="Disable Camera" onAction={disableCamera} /> | ||
| </ActionPanel> | ||
| } | ||
| /> | ||
| {cameras.map((cam) => ( | ||
| <List.Item | ||
| key={cam.uniqueId} | ||
| title={cam.name} | ||
| actions={ | ||
| <ActionPanel> | ||
| <Action title={`Switch to ${cam.name}`} onAction={() => switchCamera(cam)} /> | ||
| </ActionPanel> | ||
| } | ||
| /> | ||
| ))} | ||
| </List> | ||
| ); | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.