-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: Add deeplinks + Raycast extension support for recording control (#1540) #1571
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "name": "cap-recording-control", | ||
| "title": "Cap Recording Control", | ||
| "description": "Control Cap screen recording via deeplinks (pause, resume, start, stop, switch camera/microphone)", | ||
| "author": "Cap Software", | ||
| "version": "1.0.0", | ||
| "keywords": [ | ||
| "cap", | ||
| "screen-recording", | ||
| "recording-control", | ||
| "deeplink" | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { open, showToast, Toast } from "@raycast/api"; | ||
| import { generateDeeplink } from "../utils/deeplink"; | ||
|
|
||
| export default async function Command() { | ||
| const deeplink = generateDeeplink("pause_recording"); | ||
|
|
||
| try { | ||
| await open(deeplink); | ||
| await showToast({ style: Toast.Style.Success, title: "Opened Cap" }); | ||
| } catch (error) { | ||
| await showToast({ style: Toast.Style.Failure, title: "Error", message: String(error) }); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { open, showToast, Toast } from "@raycast/api"; | ||
| import { generateDeeplink } from "../utils/deeplink"; | ||
|
|
||
| export default async function Command() { | ||
| const deeplink = generateDeeplink("resume_recording"); | ||
|
|
||
| try { | ||
| await open(deeplink); | ||
| await showToast({ style: Toast.Style.Success, title: "Opened Cap" }); | ||
| } catch (error) { | ||
| await showToast({ style: Toast.Style.Failure, title: "Error", message: String(error) }); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,19 @@ | ||||||||||||||
| import { open, showToast, Toast } from "@raycast/api"; | ||||||||||||||
| import { generateDeeplink } from "../utils/deeplink"; | ||||||||||||||
|
|
||||||||||||||
| export default async function Command() { | ||||||||||||||
| const deeplink = generateDeeplink("start_recording", { | ||||||||||||||
|
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
|
||||||||||||||
| capture_mode: { screen: "default" }, | ||||||||||||||
| camera: null, | ||||||||||||||
| mic_label: null, | ||||||||||||||
| capture_system_audio: false, | ||||||||||||||
| mode: "normal" | ||||||||||||||
| }); | ||||||||||||||
|
|
||||||||||||||
| try { | ||||||||||||||
| await open(deeplink); | ||||||||||||||
| await showToast({ style: Toast.Style.Success, title: "Opened Cap" }); | ||||||||||||||
| } catch (error) { | ||||||||||||||
| await showToast({ style: Toast.Style.Failure, title: "Error", message: String(error) }); | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { open, showToast, Toast } from "@raycast/api"; | ||
| import { generateDeeplink } from "../utils/deeplink"; | ||
|
|
||
| export default async function Command() { | ||
| const deeplink = generateDeeplink("stop_recording"); | ||
|
|
||
| try { | ||
| await open(deeplink); | ||
| await showToast({ style: Toast.Style.Success, title: "Opened Cap" }); | ||
| } catch (error) { | ||
| await showToast({ style: Toast.Style.Failure, title: "Error", message: String(error) }); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { open, showToast, Toast } from "@raycast/api"; | ||
| import { generateDeeplink } from "../utils/deeplink"; | ||
|
|
||
| export default async function Command() { | ||
| // TODO: Replace "default" with actual device picker when available | ||
| // For now, this will use the default/primary camera device | ||
| const deeplink = generateDeeplink("switch_camera", { | ||
| device_id: "default" | ||
| }); | ||
|
|
||
| try { | ||
| await open(deeplink); | ||
| await showToast({ style: Toast.Style.Success, title: "Opened Cap" }); | ||
| } catch (error) { | ||
| await showToast({ style: Toast.Style.Failure, title: "Error", message: String(error) }); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { open, showToast, Toast } from "@raycast/api"; | ||
| import { generateDeeplink } from "../utils/deeplink"; | ||
|
|
||
| export default async function Command() { | ||
| // TODO: Replace "default" with actual mic picker when available | ||
| // For now, this will use the default/system microphone | ||
| const deeplink = generateDeeplink("switch_microphone", { | ||
| mic_label: "default" | ||
| }); | ||
|
|
||
| try { | ||
| await open(deeplink); | ||
| await showToast({ style: Toast.Style.Success, title: "Opened Cap" }); | ||
| } catch (error) { | ||
| await showToast({ style: Toast.Style.Failure, title: "Error", message: String(error) }); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /** | ||
| * Generate a deeplink for Cap recording control actions | ||
| * | ||
| * Supported actions: | ||
| * - pause_recording: {} (no params) | ||
| * - resume_recording: {} (no params) | ||
| * - stop_recording: {} (no params) | ||
| * - start_recording: { capture_mode, camera?, mic_label?, capture_system_audio, mode } | ||
| * - switch_camera: { device_id } | ||
| * - switch_microphone: { mic_label } | ||
| */ | ||
| export const generateDeeplink = (action: string, params?: Record<string, any>): string => { | ||
|
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. I only see |
||
| const validActions = [ | ||
| "pause_recording", | ||
| "resume_recording", | ||
| "stop_recording", | ||
| "start_recording", | ||
| "switch_camera", | ||
| "switch_microphone" | ||
| ]; | ||
|
|
||
| if (!validActions.includes(action)) { | ||
| throw new Error(`Invalid action: ${action}. Must be one of: ${validActions.join(", ")}`); | ||
| } | ||
|
|
||
| const url = new URL(`cap://action`); | ||
|
|
||
| const actionObj: any = {}; | ||
|
|
||
| if (params) { | ||
| actionObj[action] = params; | ||
| } else { | ||
| actionObj[action] = {}; | ||
| } | ||
|
|
||
| url.searchParams.append("value", JSON.stringify(actionObj)); | ||
| return url.toString(); | ||
| }; | ||
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.
The field is named
device_id, but this constructsDeviceOrModelID::ModelID. If the deeplink is actually passing a device id (as the Raycast command suggests), this should probably useDeviceID(and avoids the clone).