-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: Extend deeplinks support + Raycast Extension #1634
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
769066112-ops
wants to merge
2
commits into
CapSoftware:main
Choose a base branch
from
769066112-ops:feat/deeplinks-raycast-extension
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
2 commits
Select commit
Hold shift + click to select a range
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,44 @@ | ||
| # Cap Raycast Extension | ||
|
|
||
| Control [Cap](https://cap.so) screen recording directly from [Raycast](https://raycast.com). | ||
|
|
||
| ## Commands | ||
|
|
||
| | Command | Description | | ||
| |---------|-------------| | ||
| | Start Instant Recording | Start an instant screen recording | | ||
| | Start Studio Recording | Start a studio screen recording | | ||
| | Stop Recording | Stop the current recording | | ||
| | Toggle Pause Recording | Pause or resume the current recording | | ||
| | Take Screenshot | Take a screenshot | | ||
| | Open Settings | Open Cap settings | | ||
|
|
||
| ## How It Works | ||
|
|
||
| This extension communicates with the Cap desktop app via deeplinks (`cap-desktop://action?value=...`). The Cap app must be running for commands to work. | ||
|
|
||
| ## Supported Deeplink Actions | ||
|
|
||
| The following deeplink actions are available: | ||
|
|
||
| - `start_recording` — Start a recording (instant or studio mode) | ||
| - `stop_recording` — Stop the current recording | ||
| - `pause_recording` — Pause the current recording | ||
| - `resume_recording` — Resume a paused recording | ||
| - `toggle_pause` — Toggle pause/resume | ||
| - `take_screenshot` — Capture a screenshot | ||
| - `set_camera` — Switch camera input | ||
| - `set_microphone` — Switch microphone input | ||
| - `open_editor` — Open the editor for a project | ||
| - `open_settings` — Open the settings window | ||
|
|
||
| ### Deeplink Format | ||
|
|
||
| ``` | ||
| cap-desktop://action?value=<url-encoded-json> | ||
| ``` | ||
|
|
||
| Example: | ||
| ``` | ||
| cap-desktop://action?value=%7B%22stop_recording%22%3A%7B%7D%7D | ||
| ``` |
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,84 @@ | ||
| { | ||
| "$schema": "https://www.raycast.com/schemas/extension.json", | ||
| "name": "cap", | ||
| "title": "Cap", | ||
| "description": "Control Cap screen recording from Raycast", | ||
| "icon": "cap-icon.png", | ||
| "author": "cap", | ||
| "categories": ["Productivity", "Applications"], | ||
| "license": "MIT", | ||
| "preferences": [ | ||
| { | ||
| "name": "displayName", | ||
| "title": "Display Name", | ||
| "description": "Name of the display to capture (leave empty to use the main display)", | ||
| "type": "textfield", | ||
| "required": false, | ||
| "default": "" | ||
| } | ||
| ], | ||
| "commands": [ | ||
| { | ||
| "name": "start-instant-recording", | ||
| "title": "Start Instant Recording", | ||
| "subtitle": "Cap", | ||
| "description": "Start an instant screen recording with Cap", | ||
| "mode": "no-view" | ||
| }, | ||
| { | ||
| "name": "start-studio-recording", | ||
| "title": "Start Studio Recording", | ||
| "subtitle": "Cap", | ||
| "description": "Start a studio screen recording with Cap", | ||
| "mode": "no-view" | ||
| }, | ||
| { | ||
| "name": "stop-recording", | ||
| "title": "Stop Recording", | ||
| "subtitle": "Cap", | ||
| "description": "Stop the current Cap recording", | ||
| "mode": "no-view" | ||
| }, | ||
| { | ||
| "name": "toggle-pause", | ||
| "title": "Toggle Pause Recording", | ||
| "subtitle": "Cap", | ||
| "description": "Pause or resume the current Cap recording", | ||
| "mode": "no-view" | ||
| }, | ||
| { | ||
| "name": "take-screenshot", | ||
| "title": "Take Screenshot", | ||
| "subtitle": "Cap", | ||
| "description": "Take a screenshot with Cap", | ||
| "mode": "no-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.14", | ||
| "@types/node": "22.13.14", | ||
| "@types/react": "19.0.12", | ||
| "eslint": "^9.23.0", | ||
| "prettier": "^3.5.3", | ||
| "typescript": "^5.8.2" | ||
| }, | ||
| "scripts": { | ||
| "build": "ray build", | ||
| "dev": "ray develop", | ||
| "fix-lint": "ray lint --fix", | ||
| "lint": "ray lint", | ||
| "prepublishOnly": "echo \"Error: no publish\" && exit 1", | ||
| "publish": "npx @raycast/api@latest publish" | ||
| } | ||
| } |
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,8 @@ | ||
| import { executeDeepLink } from "./utils"; | ||
|
|
||
| export default async function command() { | ||
| await executeDeepLink( | ||
| { open_settings: { page: null } }, | ||
| "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,16 @@ | ||
| import { executeDeepLink, getDisplayName } from "./utils"; | ||
|
|
||
| export default async function command() { | ||
| await executeDeepLink( | ||
| { | ||
| start_recording: { | ||
| capture_mode: { screen: getDisplayName() }, | ||
| camera: null, | ||
| mic_label: null, | ||
| capture_system_audio: false, | ||
| mode: "instant", | ||
| }, | ||
| }, | ||
| "Starting instant recording...", | ||
| ); | ||
| } |
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,16 @@ | ||
| import { executeDeepLink, getDisplayName } from "./utils"; | ||
|
|
||
| export default async function command() { | ||
| await executeDeepLink( | ||
| { | ||
| start_recording: { | ||
| capture_mode: { screen: getDisplayName() }, | ||
| camera: null, | ||
| mic_label: null, | ||
| capture_system_audio: false, | ||
| mode: "studio", | ||
| }, | ||
| }, | ||
| "Starting studio recording...", | ||
| ); | ||
| } |
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 command() { | ||
| await executeDeepLink({ stop_recording: {} }, "Stopping recording..."); | ||
| } |
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, getDisplayName } from "./utils"; | ||
|
|
||
| export default async function command() { | ||
| await executeDeepLink( | ||
| { | ||
| take_screenshot: { | ||
| capture_mode: { screen: getDisplayName() }, | ||
| }, | ||
| }, | ||
| "Taking screenshot...", | ||
| ); | ||
| } |
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 command() { | ||
| await executeDeepLink({ toggle_pause: {} }, "Toggling pause..."); | ||
| } |
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,35 @@ | ||||||||||||||||||||
| import { getPreferenceValues, open, showToast, Toast } from "@raycast/api"; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const DEEPLINK_SCHEME = "cap-desktop"; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| interface Preferences { | ||||||||||||||||||||
| displayName: string; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| export function getDisplayName(): string { | ||||||||||||||||||||
| const { displayName } = getPreferenceValues<Preferences>(); | ||||||||||||||||||||
| return displayName || "Main Display"; | ||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| export function buildDeepLink(action: Record<string, unknown>): string { | ||||||||||||||||||||
| const json = JSON.stringify(action); | ||||||||||||||||||||
| return `${DEEPLINK_SCHEME}://action?value=${encodeURIComponent(json)}`; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| export async function executeDeepLink( | ||||||||||||||||||||
| action: Record<string, unknown>, | ||||||||||||||||||||
| successMessage: string, | ||||||||||||||||||||
| ): Promise<void> { | ||||||||||||||||||||
| const url = buildDeepLink(action); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| try { | ||||||||||||||||||||
| await open(url); | ||||||||||||||||||||
| await showToast({ style: Toast.Style.Success, title: successMessage }); | ||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||
| await showToast({ | ||||||||||||||||||||
| style: Toast.Style.Failure, | ||||||||||||||||||||
| title: "Failed to communicate with Cap", | ||||||||||||||||||||
| message: String(error), | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
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,19 @@ | ||
| { | ||
| "$schema": "https://json.schemastore.org/tsconfig", | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "checkJs": false, | ||
| "declaration": true, | ||
| "esModuleInterop": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "jsx": "react-jsx", | ||
| "lib": ["ES2023"], | ||
| "module": "Node16", | ||
| "moduleResolution": "Node16", | ||
| "resolveJsonModule": true, | ||
| "skipLibCheck": true, | ||
| "strict": true, | ||
| "target": "ES2022" | ||
| }, | ||
| "include": ["src/**/*", "env.d.ts"] | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If clients send an empty screen name (Raycast pref “leave empty to use main display”), we currently error. Might be worth treating empty (and maybe "Main Display" for compatibility) as “pick a default display” so deeplinks work out of the box.