Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

make system audio an experimental feature (#433)

Brendan Allan480fc9a79026
diff --git a/apps/desktop/src-tauri/src/general_settings.rs b/apps/desktop/src-tauri/src/general_settings.rs
index a7ccbfcbd..9c73bce05 100644
--- a/apps/desktop/src-tauri/src/general_settings.rs
+++ b/apps/desktop/src-tauri/src/general_settings.rs
@@ -55,6 +55,8 @@ pub struct GeneralSettingsStore {
pub main_window_recording_start_behaviour: MainWindowRecordingStartBehaviour,
#[serde(default)]
pub custom_cursor_capture: bool,
+ #[serde(default)]
+ pub system_audio_capture: bool,
#[serde(default, alias = "open_editor_after_recording")]
#[deprecated]
_open_editor_after_recording: bool,
@@ -87,6 +89,7 @@ impl Default for GeneralSettingsStore {
post_studio_recording_behaviour: PostStudioRecordingBehaviour::OpenEditor,
main_window_recording_start_behaviour: MainWindowRecordingStartBehaviour::Close,
custom_cursor_capture: false,
+ system_audio_capture: false,
_open_editor_after_recording: false,
}
}
diff --git a/apps/desktop/src/routes/(window-chrome)/(main).tsx b/apps/desktop/src/routes/(window-chrome)/(main).tsx
index 010402c31..0b91648b7 100644
--- a/apps/desktop/src/routes/(window-chrome)/(main).tsx
+++ b/apps/desktop/src/routes/(window-chrome)/(main).tsx
@@ -42,14 +42,17 @@ import {
events,
} from "~/utils/tauri";
-const MAIN_WINDOW_SIZE = {
- width: 300,
- height: 290 + (window.FLAGS.systemAudioRecording ? 50 : 0),
-};
+function getWindowSize(systemAudioRecording: boolean) {
+ return {
+ width: 300,
+ height: 290 + (systemAudioRecording ? 50 : 0),
+ };
+}
export default function () {
const { options, setOptions } = createOptionsQuery();
const currentRecording = createCurrentRecordingQuery();
+ const generalSettings = generalSettingsStore.createQuery();
const isRecording = () => !!currentRecording.data;
@@ -125,27 +128,26 @@ export default function () {
// Enforce window size with multiple safeguards
const currentWindow = getCurrentWindow();
- // Set initial size
- await currentWindow.setSize(
- new LogicalSize(MAIN_WINDOW_SIZE.width, MAIN_WINDOW_SIZE.height)
- );
-
// Check size when app regains focus
const unlistenFocus = await currentWindow.onFocusChanged(
({ payload: focused }) => {
if (focused) {
- currentWindow.setSize(
- new LogicalSize(MAIN_WINDOW_SIZE.width, MAIN_WINDOW_SIZE.height)
+ const size = getWindowSize(
+ generalSettings.data?.systemAudioCapture ?? false
);
+
+ currentWindow.setSize(new LogicalSize(size.width, size.height));
}
}
);
// Listen for resize events
const unlistenResize = await currentWindow.onResized(() => {
- currentWindow.setSize(
- new LogicalSize(MAIN_WINDOW_SIZE.width, MAIN_WINDOW_SIZE.height)
+ const size = getWindowSize(
+ generalSettings.data?.systemAudioCapture ?? false
);
+
+ currentWindow.setSize(new LogicalSize(size.width, size.height));
});
unlistenFn = () => {
@@ -235,6 +237,13 @@ export default function () {
),
});
+ createEffect(() => {
+ const size = getWindowSize(
+ generalSettings.data?.systemAudioCapture ?? false
+ );
+ getCurrentWindow().setSize(new LogicalSize(size.width, size.height));
+ });
+
return (
<div class="flex justify-center flex-col p-[1rem] gap-[0.75rem] text-[0.875rem] font-[400] bg-[--gray-50] h-full text-[--text-primary]">
{initialize()}
@@ -280,7 +289,7 @@ export default function () {
<TargetSelects options={options.data} setOptions={setOptions} />
<CameraSelect options={options.data} setOptions={setOptions} />
<MicrophoneSelect options={options.data} setOptions={setOptions} />
- {window.FLAGS.systemAudioRecording && (
+ {generalSettings.data?.systemAudioCapture && (
<SystemAudio options={options.data} setOptions={setOptions} />
)}
<div class="flex items-center space-x-1 w-full">
@@ -352,7 +361,7 @@ import { Transition } from "solid-transition-group";
import { apiClient } from "~/utils/web-api";
import { useWindowChrome } from "./Context";
-import { authStore } from "~/store";
+import { authStore, generalSettingsStore } from "~/store";
let hasChecked = false;
function createUpdateCheck() {
diff --git a/apps/desktop/src/routes/(window-chrome)/settings/general.tsx b/apps/desktop/src/routes/(window-chrome)/settings/general.tsx
index 2109a449a..31527033c 100644
--- a/apps/desktop/src/routes/(window-chrome)/settings/general.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/settings/general.tsx
@@ -122,6 +122,25 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {
generalSettingsStore.set({ theme: newTheme });
}}
/>
+ <ToggleSetting
+ pro
+ label="Disable automatic link opening"
+ description="When enabled, Cap will not automatically open links in your browser (e.g. after creating a shareable link)."
+ value={!!settings.disableAutoOpenLinks}
+ onChange={(value) => handleChange("disableAutoOpenLinks", value)}
+ />
+ <ToggleSetting
+ label="Enable custom cursor capture in Studio Mode (Experimental)"
+ description="Whether Studio Mode recordings should capture cursor state separately, for customisation (size, smoothing) in the editor. Currently experimental as cursor events may not be captured accurately."
+ value={!!settings.customCursorCapture}
+ onChange={(value) => handleChange("customCursorCapture", value)}
+ />
+ <ToggleSetting
+ label="System audio capture (Experimental)"
+ description="Provides the option for you to capture audio coming from your system, such as music or video playback."
+ value={!!settings.systemAudioCapture}
+ onChange={(value) => handleChange("systemAudioCapture", value)}
+ />
{ostype === "macos" && (
<>
<ToggleSetting
@@ -138,13 +157,6 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {
/>
</>
)}
- <ToggleSetting
- pro
- label="Disable automatic link opening"
- description="When enabled, Cap will not automatically open links in your browser (e.g. after creating a shareable link)."
- value={!!settings.disableAutoOpenLinks}
- onChange={(value) => handleChange("disableAutoOpenLinks", value)}
- />
<ToggleSetting
label="Enable system notifications"
description="Show system notifications for events like copying to clipboard, saving files, and more. You may need to manually allow Cap access via your system's notification settings."
@@ -243,12 +255,6 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {
<IconCapChevronDown class="size-4" />
</button>
</Setting>
- <ToggleSetting
- label="Enable custom cursor capture in Studio Mode (Experimental)"
- description="Whether Studio Mode recordings should capture cursor state separately, for customisation (size, smoothing) in the editor. Currently experimental as cursor events may not be captured accurately."
- value={!!settings.customCursorCapture}
- onChange={(value) => handleChange("customCursorCapture", value)}
- />
</div>
</div>
</div>
diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.ts
index defa377f9..def340eb5 100644
--- a/apps/desktop/src/utils/tauri.ts
+++ b/apps/desktop/src/utils/tauri.ts
@@ -253,7 +253,7 @@ export type Cursors = { [key in string]: string } | { [key in string]: CursorMet
export type EditorStateChanged = { playhead_position: number }
export type ExportEstimates = { duration_seconds: number; estimated_time_seconds: number; estimated_size_mb: number }
export type Flags = { systemAudioRecording: boolean; split: boolean }
-export type GeneralSettingsStore = { instanceId?: string; uploadIndividualFiles?: boolean; hideDockIcon?: boolean; hapticsEnabled?: boolean; autoCreateShareableLink?: boolean; enableNotifications?: boolean; disableAutoOpenLinks?: boolean; hasCompletedStartup?: boolean; theme?: AppTheme; commercialLicense?: CommercialLicense | null; lastVersion?: string | null; windowTransparency?: boolean; postStudioRecordingBehaviour?: PostStudioRecordingBehaviour; mainWindowRecordingStartBehaviour?: MainWindowRecordingStartBehaviour; customCursorCapture?: boolean;
+export type GeneralSettingsStore = { instanceId?: string; uploadIndividualFiles?: boolean; hideDockIcon?: boolean; hapticsEnabled?: boolean; autoCreateShareableLink?: boolean; enableNotifications?: boolean; disableAutoOpenLinks?: boolean; hasCompletedStartup?: boolean; theme?: AppTheme; commercialLicense?: CommercialLicense | null; lastVersion?: string | null; windowTransparency?: boolean; postStudioRecordingBehaviour?: PostStudioRecordingBehaviour; mainWindowRecordingStartBehaviour?: MainWindowRecordingStartBehaviour; customCursorCapture?: boolean; systemAudioCapture?: boolean;
/**
* @deprecated
*/