Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Add screenshot sound and refine notification audio

Richie McIlroya67df5a20c74
diff --git a/apps/desktop/src-tauri/src/audio.rs b/apps/desktop/src-tauri/src/audio.rs
index b8319f8e5..7cca0218f 100644
--- a/apps/desktop/src-tauri/src/audio.rs
+++ b/apps/desktop/src-tauri/src/audio.rs
@@ -18,6 +18,7 @@ fn play_audio(bytes: &'static [u8]) {
pub enum AppSounds {
StartRecording,
StopRecording,
+ Screenshot,
Notification,
}
@@ -31,6 +32,7 @@ impl AppSounds {
match self {
AppSounds::StartRecording => include_bytes!("../sounds/start-recording.ogg"),
AppSounds::StopRecording => include_bytes!("../sounds/stop-recording.ogg"),
+ AppSounds::Screenshot => include_bytes!("../sounds/screenshot.ogg"),
AppSounds::Notification => include_bytes!("../sounds/action.ogg"),
}
}
diff --git a/apps/desktop/src-tauri/src/notifications.rs b/apps/desktop/src-tauri/src/notifications.rs
index c61e24b97..d872fd838 100644
--- a/apps/desktop/src-tauri/src/notifications.rs
+++ b/apps/desktop/src-tauri/src/notifications.rs
@@ -89,7 +89,6 @@ impl NotificationType {
}
pub fn send_notification(app: &tauri::AppHandle, notification_type: NotificationType) {
- // Check if notifications are enabled in settings
let enable_notifications = GeneralSettingsStore::get(app)
.map(|settings| settings.is_some_and(|s| s.enable_notifications))
.unwrap_or(false);
@@ -107,5 +106,15 @@ pub fn send_notification(app: &tauri::AppHandle, notification_type: Notification
.show()
.ok();
- AppSounds::Notification.play();
+ let skip_sound = matches!(
+ notification_type,
+ NotificationType::ScreenshotSaved
+ | NotificationType::ScreenshotCopiedToClipboard
+ | NotificationType::ScreenshotSaveFailed
+ | NotificationType::ScreenshotCopyFailed
+ );
+
+ if !skip_sound {
+ AppSounds::Notification.play();
+ }
}
diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rs
index ecdab8f75..d277e5b13 100644
--- a/apps/desktop/src-tauri/src/recording.rs
+++ b/apps/desktop/src-tauri/src/recording.rs
@@ -1205,6 +1205,8 @@ pub async fn take_screenshot(
.await
.map_err(|e| format!("Failed to capture screenshot: {e}"))?;
+ AppSounds::Notification.play();
+
let image_width = image.width();
let image_height = image.height();
let image_data = image.into_raw();
@@ -1316,8 +1318,6 @@ pub async fn take_screenshot(
&app_handle,
notifications::NotificationType::ScreenshotSaved,
);
-
- AppSounds::StopRecording.play();
}
Ok(Err(e)) => {
error!("Failed to encode PNG: {e}");