Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

update branch with CapSoftware/cap main

PJ4f94cf8b7ea5
diff --cc apps/desktop/package.json
index f50e766b4,68a1154ec..198ed704a
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@@ -1,9 -1,9 +1,9 @@@
{
"name": "desktop",
"private": true,
- "version": "0.2.7",
+ "version": "0.2.8",
"scripts": {
- "dev": "RUST_BACKTRACE=1 tauri dev",
+ "dev": "tauri dev",
"build": "tsc && next build",
"tauri": "tauri"
},
diff --cc apps/desktop/src-tauri/src/app/commands.rs
index ef2b9b750,000000000..b57c0aba3
mode 100644,000000..100644
--- a/apps/desktop/src-tauri/src/app/commands.rs
+++ b/apps/desktop/src-tauri/src/app/commands.rs
@@@ -1,95 -1,0 +1,95 @@@
+use tauri::Window;
+use tauri_plugin_oauth::start;
+
+macro_rules! generate_handler {
+ ($($command:ident),*) => {{
- #[cfg(debug_assertions)]
- tauri_specta::ts::export(
- specta::collect_types![$($command),*],
- "../../src/utils/commands.ts"
- ).unwrap();
++ #[cfg(debug_assertions)]
++ tauri_specta::ts::export(
++ specta::collect_types![$($command),*],
++ "../../src/utils/commands.ts"
++ ).unwrap();
+
- tauri::generate_handler![$($command),*]
++ tauri::generate_handler![$($command),*]
+ }}
+}
+
+#[tauri::command]
+#[specta::specta]
+pub async fn start_server(window: Window) -> Result<u16, String> {
+ start(move |url| {
+ let _ = window.emit("redirect_uri", url);
+ })
+ .map_err(|err| err.to_string())
+}
+
+#[tauri::command]
+#[specta::specta]
+pub fn has_screen_capture_access() -> bool {
+ scap::has_permission()
+}
+
+#[tauri::command]
+#[specta::specta]
+pub fn open_screen_capture_preferences() {
+ #[cfg(target_os = "macos")]
+ std::process::Command::new("open")
+ .arg("x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture")
+ .spawn()
+ .expect("failed to open system preferences");
+}
+
+#[tauri::command]
+#[specta::specta]
+pub fn open_mic_preferences() {
+ #[cfg(target_os = "macos")]
+ std::process::Command::new("open")
+ .arg("x-apple.systempreferences:com.apple.preference.security?Privacy_Microphone")
+ .spawn()
+ .expect("failed to open system preferences");
+}
+
+#[tauri::command]
+#[specta::specta]
+pub fn open_camera_preferences() {
+ #[cfg(target_os = "macos")]
+ std::process::Command::new("open")
+ .arg("x-apple.systempreferences:com.apple.preference.security?Privacy_Camera")
+ .spawn()
+ .expect("failed to open system preferences");
+}
+
+#[tauri::command]
+#[specta::specta]
+pub fn reset_screen_permissions() {
+ #[cfg(target_os = "macos")]
+ std::process::Command::new("tccutil")
+ .arg("reset")
+ .arg("ScreenCapture")
+ .arg("so.cap.desktop")
+ .spawn()
+ .expect("failed to reset screen permissions");
+}
+
+#[tauri::command]
+#[specta::specta]
+pub fn reset_microphone_permissions() {
+ #[cfg(target_os = "macos")]
+ std::process::Command::new("tccutil")
+ .arg("reset")
+ .arg("Microphone")
+ .arg("so.cap.desktop")
+ .spawn()
+ .expect("failed to reset microphone permissions");
+}
+
+#[tauri::command]
+#[specta::specta]
+pub fn reset_camera_permissions() {
+ #[cfg(target_os = "macos")]
+ std::process::Command::new("tccutil")
+ .arg("reset")
+ .arg("Camera")
+ .arg("so.cap.desktop")
+ .spawn()
+ .expect("failed to reset camera permissions");
+}
diff --cc apps/desktop/src-tauri/src/app/mod.rs
index e695941b8,b25fcc069..f85e9c9d7
--- a/apps/desktop/src-tauri/src/app/mod.rs
+++ b/apps/desktop/src-tauri/src/app/mod.rs
@@@ -5,10 -5,8 +5,10 @@@ use std::
time::{Duration, SystemTime},
};
use tauri::{Assets, Context};
- use tracing_appender::rolling::RollingFileAppender;
+ use tracing_appender::rolling::{RollingFileAppender, Rotation};
+#[macro_use]
+pub mod commands;
pub mod config;
pub fn panic_hook(info: &PanicInfo) {
diff --cc apps/desktop/src-tauri/src/main.rs
index 5cd4e83f6,5b8f710ed..cf7222109
--- a/apps/desktop/src-tauri/src/main.rs
+++ b/apps/desktop/src-tauri/src/main.rs
@@@ -103,8 -119,87 +103,12 @@@ fn main()
Ok(())
}
- handle_ffmpeg_installation().expect("Failed to install FFmpeg");
+ if let Err(error) = handle_ffmpeg_installation() {
+ tracing::error!(error);
+ // TODO: UI message instead
+ panic!("Failed to install FFmpeg, which is required for Cap to function. Shutting down now")
+ };
- #[tauri::command]
- #[specta::specta]
- async fn start_server(window: Window) -> Result<u16, String> {
- start(move |url| {
- let _ = window.emit("redirect_uri", url);
- })
- .map_err(|err| err.to_string())
- }
-
- #[tauri::command]
- #[specta::specta]
- fn open_screen_capture_preferences() {
- #[cfg(target_os = "macos")]
- std::process::Command::new("open")
- .arg("x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture")
- .spawn()
- .expect("failed to open system preferences");
- }
-
- #[tauri::command]
- #[specta::specta]
- fn open_mic_preferences() {
- #[cfg(target_os = "macos")]
- std::process::Command::new("open")
- .arg("x-apple.systempreferences:com.apple.preference.security?Privacy_Microphone")
- .spawn()
- .expect("failed to open system preferences");
- }
-
- #[tauri::command]
- #[specta::specta]
- fn open_camera_preferences() {
- #[cfg(target_os = "macos")]
- std::process::Command::new("open")
- .arg("x-apple.systempreferences:com.apple.preference.security?Privacy_Camera")
- .spawn()
- .expect("failed to open system preferences");
- }
-
- #[tauri::command]
- #[specta::specta]
- fn reset_screen_permissions() {
- #[cfg(target_os = "macos")]
- std::process::Command::new("tccutil")
- .arg("reset")
- .arg("ScreenCapture")
- .arg("so.cap.desktop")
- .spawn()
- .expect("failed to reset screen permissions");
- }
-
- #[tauri::command]
- #[specta::specta]
- fn reset_microphone_permissions() {
- #[cfg(target_os = "macos")]
- std::process::Command::new("tccutil")
- .arg("reset")
- .arg("Microphone")
- .arg("so.cap.desktop")
- .spawn()
- .expect("failed to reset microphone permissions");
- }
-
- #[tauri::command]
- #[specta::specta]
- fn reset_camera_permissions() {
- #[cfg(target_os = "macos")]
- std::process::Command::new("tccutil")
- .arg("reset")
- .arg("Camera")
- .arg("so.cap.desktop")
- .spawn()
- .expect("failed to reset camera permissions");
- }
-
let event_loop = winit::event_loop::EventLoop::new().expect("Failed to create event loop");
let monitor: MonitorHandle = event_loop
.primary_monitor()