Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

feat: use human friendly monitor names (#1272)

ologbonowiwi7f074164793a
diff --git a/screenpipe-vision/Cargo.toml b/screenpipe-vision/Cargo.toml
index aebc8628a..a700b2a18 100644
--- a/screenpipe-vision/Cargo.toml
+++ b/screenpipe-vision/Cargo.toml
@@ -42,6 +42,9 @@ tracing = { workspace = true }
which = "6.0"
serde = "1.0.200"
+# TO-DO: use a released version. Done for now to avoid waiting xcap release.
+xcap = { package = "xcap", git = "https://github.com/nashaofu/xcap", rev = "214cb44" }
+
once_cell = { workspace = true }
chrono = { version = "0.4.39", features = ["serde"] }
base64 = "0.22.1"
@@ -96,13 +99,10 @@ windows = { version = "0.58", features = [
"Storage",
"Storage_Streams",
] }
-xcap = "0.0.12"
[target.'cfg(target_os = "macos")'.dependencies]
libc = "=0.2.164"
-xcap-macos = { package = "xcap", git = "https://github.com/mediar-ai/xcap", rev = "965bc99" }
cidre = { git = "https://github.com/yury/cidre.git", version = "0.5.0" }
[target.'cfg(target_os = "linux")'.dependencies]
libc = "=0.2.164"
-xcap = "0.0.14"
diff --git a/screenpipe-vision/src/capture_screenshot_by_window.rs b/screenpipe-vision/src/capture_screenshot_by_window.rs
index a87248219..4524ce7b3 100644
--- a/screenpipe-vision/src/capture_screenshot_by_window.rs
+++ b/screenpipe-vision/src/capture_screenshot_by_window.rs
@@ -7,10 +7,6 @@ use std::fmt;
use std::time::Duration;
use tokio::time;
-#[cfg(target_os = "macos")]
-use xcap_macos::{Monitor, Window, XCapError};
-
-#[cfg(not(target_os = "macos"))]
use xcap::{Monitor, Window, XCapError};
#[derive(Debug)]
@@ -238,7 +234,7 @@ pub async fn capture_all_visible_windows(
image,
app_name: app_name.to_string(),
window_name: window_name.to_string(),
- is_focused: is_valid,
+ is_focused: window.is_focused(),
});
}
Err(e) => error!(
@@ -260,13 +256,8 @@ pub fn is_valid_window(
capture_unfocused_windows: bool,
) -> bool {
if !capture_unfocused_windows {
- // Early returns for simple checks
- #[cfg(target_os = "macos")]
let is_focused = window.current_monitor().id() == monitor.id() && window.is_focused();
- #[cfg(not(target_os = "macos"))]
- let is_focused = window.current_monitor().id() == monitor.id() && !window.is_minimized();
-
if !is_focused {
return false;
}
diff --git a/screenpipe-vision/src/core.rs b/screenpipe-vision/src/core.rs
index 0f45260e7..cd6539591 100644
--- a/screenpipe-vision/src/core.rs
+++ b/screenpipe-vision/src/core.rs
@@ -31,10 +31,6 @@ use tokio::io::{AsyncBufReadExt, BufReader};
use tokio::sync::mpsc::Sender;
use tokio::time::sleep;
-#[cfg(target_os = "macos")]
-use xcap_macos::Monitor;
-
-#[cfg(not(target_os = "macos"))]
use xcap::Monitor;
fn serialize_image<S>(image: &Option<DynamicImage>, serializer: S) -> Result<S::Ok, S::Error>
diff --git a/screenpipe-vision/src/monitor.rs b/screenpipe-vision/src/monitor.rs
index c48f07a48..133a0889a 100644
--- a/screenpipe-vision/src/monitor.rs
+++ b/screenpipe-vision/src/monitor.rs
@@ -1,7 +1,3 @@
-#[cfg(target_os = "macos")]
-use xcap_macos::Monitor;
-
-#[cfg(not(target_os = "macos"))]
use xcap::Monitor;
pub async fn list_monitors() -> Vec<Monitor> {
diff --git a/screenpipe-vision/src/utils.rs b/screenpipe-vision/src/utils.rs
index 28a8f2349..9a21585a7 100644
--- a/screenpipe-vision/src/utils.rs
+++ b/screenpipe-vision/src/utils.rs
@@ -9,10 +9,6 @@ use log::{debug, error, warn};
use std::hash::{DefaultHasher, Hash, Hasher};
use std::time::{Duration, Instant};
-#[cfg(target_os = "macos")]
-use xcap_macos::Monitor;
-
-#[cfg(not(target_os = "macos"))]
use xcap::Monitor;
#[derive(Clone, Debug, Default)]