Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Use arboard for copy command
Ilya1f4264a87ca7
diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rsindex c4b55d35d..354fbf1b6 100644--- a/apps/desktop/src-tauri/src/lib.rs+++ b/apps/desktop/src-tauri/src/lib.rs@@ -1628,7 +1628,7 @@ pub async fn run() {windows::position_traffic_lights,global_message_dialog,show_window,- platform::macos::write_string_to_pasteboard,+ write_clipboard_string,]).events(tauri_specta::collect_events![RecordingOptionsChanged,@@ -2029,6 +2029,20 @@ fn global_message_dialog(app: AppHandle, message: String) {app.dialog().message(message).show(|_| {});}+#[tauri::command]+#[specta::specta]+fn write_clipboard_string(+ clipboard: MutableState<'_, Clipboard>,+ text: String,+) -> Result<(), String> {+ let mut writer = clipboard+ .try_write()+ .map_err(|e| format!("Failed to acquire lock on clipboard state: {e}"))?;+ writer+ .set_text(text)+ .map_err(|e| format!("Failed to write text to clipboard: {e}"))+}+trait EventExt: tauri_specta::Event {fn listen_any_spawn<Fut>(app: &AppHandle,diff --git a/apps/desktop/src-tauri/src/platform/macos/mod.rs b/apps/desktop/src-tauri/src/platform/macos/mod.rsindex 058984b6d..46622e89d 100644--- a/apps/desktop/src-tauri/src/platform/macos/mod.rs+++ b/apps/desktop/src-tauri/src/platform/macos/mod.rs@@ -55,24 +55,6 @@ extern "C" {rect: *mut CGRect,) -> boolean_t;}-#[tauri::command]-#[specta::specta]-pub fn write_string_to_pasteboard(string: &str) {- use cocoa::appkit::NSPasteboard;- use cocoa::base::{id, nil};- use cocoa::foundation::{NSArray, NSString};- use objc::rc::autoreleasepool;-- unsafe {- autoreleasepool(|| {- let pasteboard: id = NSPasteboard::generalPasteboard(nil);- NSPasteboard::clearContents(pasteboard);- let ns_string = NSString::alloc(nil).init_str(string);- let objects: id = NSArray::arrayWithObject(nil, ns_string);- NSPasteboard::writeObjects(pasteboard, objects);- });- }-}/// Makes the background of the WKWebView layer transparent./// This differs from Tauri's implementation as it does not change the window background which causes performance performance issues and artifacts when shadows are enabled on the window.diff --git a/apps/desktop/src/routes/prev-recordings.tsx b/apps/desktop/src/routes/prev-recordings.tsxindex ea3191a88..755ed3eca 100644--- a/apps/desktop/src/routes/prev-recordings.tsx+++ b/apps/desktop/src/routes/prev-recordings.tsx@@ -891,7 +891,7 @@ function createRecordingMutations(setProgressState({ type: "idle" });}, 1500);- await commands.writeStringToPasteboard(recordingMeta.data.sharing.link);+ await commands.writeClipboardString(recordingMeta.data.sharing.link);return;}diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.tsindex b01b364bd..8d9a73238 100644--- a/apps/desktop/src/utils/tauri.ts+++ b/apps/desktop/src/utils/tauri.ts@@ -155,8 +155,8 @@ async globalMessageDialog(message: string) : Promise<void> {async showWindow(window: ShowCapWindow) : Promise<void> {await TAURI_INVOKE("show_window", { window });},-async writeStringToPasteboard(string: string) : Promise<void> {- await TAURI_INVOKE("write_string_to_pasteboard", { string });+async writeClipboardString(text: string) : Promise<null> {+ return await TAURI_INVOKE("write_clipboard_string", { text });}}