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

v0

Louis Beaumonta6712d2d78da
diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml
new file mode 100644
index 000000000..ae6c5d757
--- /dev/null
+++ b/.github/workflows/fossa.yml
@@ -0,0 +1,9 @@
+on: [push]
+jobs:
+ fossa-scan:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - uses: fossas/fossa-action@main # Use a specific version if locking is preferred
+ with:
+ api-key: ${{secrets.fossaApiKey}}
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 000000000..e8a814cbd
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,46 @@
+name: Release
+
+on:
+ push:
+ tags:
+ - 'v*.*.*'
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+
+ - name: Set up Rust
+ uses: actions-rs/toolchain@v1
+ with:
+ toolchain: stable
+ profile: minimal
+ override: true
+
+ - name: Build
+ run: cargo build --release
+
+ - name: Create Release
+ id: create_release
+ uses: actions/create-release@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ tag_name: ${{ github.ref }}
+ release_name: Release ${{ github.ref }}
+ draft: false
+ prerelease: false
+
+ - name: Upload Release Asset
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
+ asset_path: target/release/screenpipe
+ asset_name: screenpipe
+ asset_content_type: application/octet-stream
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..f86f4ad1e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,18 @@
+# Binaries for programs and examples
+*.exe
+*.exe~
+*.dll
+*.dylib
+*.so
+
+# Test binary, built with `cargo test`
+*.test
+
+# Rust/Cargo specific files
+*target
+*Cargo.lock
+
+# IDE specific files
+.idea/
+.vscode/
+*.rs.bk
\ No newline at end of file
diff --git a/README.md b/README.md
index ab39864ed..8eadd19b4 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,9 @@
# screen-pipe
## Overview
-**ScreenPipe** is a versatile library designed to facilitate the piping of screen data—including frames, video, OCR text, and metadata—from multiple screens to a defined storage solution, designed to be processed by LLMs. Written in Rust and compiled to WebAssembly (WASM), it ensures high performance and cross-platform compatibility, making it suitable for use on macOS, Linux, Windows, and other platforms.
+**ScreenPipe** is a versatile library designed to facilitate the piping of screen data—including frames, video, OCR text, and metadata—from multiple screens to a defined storage solution, designed to be processed by **LLMs**. Written in Rust and compiled to WebAssembly (WASM), it ensures high performance and cross-platform compatibility, making it suitable for use on macOS, Linux, Windows, and other platforms.
-Takes inspiration on adept.ai, rewind.ai, Apple Shortcut, and more.
+Takes inspiration on `adept.ai`, `rewind.ai`, `Apple Shortcut`, and more.
## Features
- **Multi-Screen Support**: Capture and aggregate data from multiple screens simultaneously.
@@ -18,9 +18,7 @@ Takes inspiration on adept.ai, rewind.ai, Apple Shortcut, and more.
To install ScreenPipe, run the following command in your terminal:
```bash
-brew install screenpipe
-# or
-apt install screenpipe
+curl -sL https://raw.githubusercontent.com/louis030195/screen-pipe/main/install.sh | sh
```
## Usage
@@ -44,6 +42,7 @@ const screenPipe = new ScreenPipe();
export async function onTick() {
const data = await screenPipe.tick([1], {frames: 60}); // or screen [1, 2, 3, ...]
+ // [{frame: [...], text: [...], metadata: [...]}, ...]
const { object } = await generateObject({
model: openai("gpt4-o"),
diff --git a/install.sh b/install.sh
new file mode 100644
index 000000000..ee1867419
--- /dev/null
+++ b/install.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Define the GitHub repository
+REPO="louis030195/screen-pipe"
+
+# Get the latest release
+LATEST_RELEASE=$(curl -s https://api.github.com/repos/$REPO/releases/latest | grep "tag_name" | cut -d '"' -f 4)
+
+# Download the latest release binary
+curl -L "https://github.com/$REPO/releases/download/$LATEST_RELEASE/screenpipe" -o /usr/local/bin/screenpipe
+
+# Make the binary executable
+chmod +x /usr/local/bin/screenpipe
+
+echo "screenpipe installed successfully!"
\ No newline at end of file
diff --git a/screenpipe/Cargo.toml b/screenpipe/Cargo.toml
new file mode 100644
index 000000000..6b0c17ed0
--- /dev/null
+++ b/screenpipe/Cargo.toml
@@ -0,0 +1,15 @@
+[package]
+name = "screenpipe"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
+xcap = "0.0.10"
+clap = { version = "4.0", features = ["derive"] }
+chrono = "0.4.38"
+crossbeam = "0.8"
+ctrlc = "3.4"
+
+[[bin]]
+name = "screenpipe"
+path = "src/main.rs"
diff --git a/screenpipe/src/main.rs b/screenpipe/src/main.rs
new file mode 100644
index 000000000..44735a5d1
--- /dev/null
+++ b/screenpipe/src/main.rs
@@ -0,0 +1,105 @@
+use chrono::Local;
+use clap::Parser;
+use crossbeam::channel;
+use std::fs::create_dir_all;
+use std::sync::atomic::{AtomicBool, Ordering};
+use std::sync::Arc;
+use std::thread::{self, sleep};
+use std::time::{Duration, Instant};
+use xcap::image::{ImageBuffer, Rgba};
+use xcap::Monitor;
+const DISPLAY: &str = r"
+ ___ ___ ___ ___ ___ ___ ___ ___ ___
+ / /\ / /\ / /\ / /\ / /\ /__/\ / /\ ___ / /\ / /\
+ / /:/_ / /:/ / /::\ / /:/_ / /:/_ \ \:\ / /::\ / /\ / /::\ / /:/_
+ / /:/ /\ / /:/ / /:/\:\ / /:/ /\ / /:/ /\ \ \:\ / /:/\:\/ /:/ / /:/\:\/ /:/ /\
+ / /:/ /::\ / /:/ ___ / /:/~/:/ / /:/ /:/_ / /:/ /:/_ _____\__\:\ / /:/~/:/__/::\ / /:/~/:/ /:/ /:/_
+ /__/:/ /:/\:/__/:/ / //__/:/ /:/__/__/:/ /:/ //__/:/ /:/ //__/::::::::\ /__/:/ /:/\__\/\:\__/__/:/ /:/__/:/ /:/ /\
+ \ \:\/:/~/:\ \:\ / /:\ \:\/:::::\ \:\/:/ /:\ \:\/:/ /:\ \:\~~\~~\/ \ \:\/:/ \ \:\/\ \:\/:/\ \:\/:/ /:/
+ \ \::/ /:/ \ \:\ /:/ \ \::/~~~~ \ \::/ /:/ \ \::/ /:/ \ \:\ ~~~ \ \::/ \__\::/\ \::/ \ \::/ /:/
+ \__\/ /:/ \ \:\/:/ \ \:\ \ \:\/:/ \ \:\/:/ \ \:\ \ \:\ /__/:/ \ \:\ \ \:\/:/
+ /__/:/ \ \::/ \ \:\ \ \::/ \ \::/ \ \:\ \ \:\ \__\/ \ \:\ \ \::/
+ \__\/ \__\/ \__\/ \__\/ \__\/ \__\/ \__\/ \__\/ \__\/
+
+";
+
+#[derive(Parser)]
+#[command(name = "screenpipe")]
+#[command(about = "A tool to capture screenshots at regular intervals", long_about = None)]
+struct Cli {
+ /// Path to save screenshots
+ #[arg(short, long, default_value = "target/screenshots")]
+ path: String,
+
+ /// Interval in seconds between screenshots (can be float, by default no delay)
+ #[arg(short, long, default_value_t = 0.0)]
+ interval: f32,
+}
+
+fn normalized(filename: &str) -> String {
+ filename
+ .replace("|", "")
+ .replace("\\", "")
+ .replace(":", "")
+ .replace("/", "")
+}
+
+fn screenpipe(path: &str, interval: f32, running: Arc<AtomicBool>) {
+ // delete and recreate the directory
+ println!("Deleting and recreating directory {}", path);
+ std::fs::remove_dir_all(path).unwrap();
+ create_dir_all(path).unwrap();
+ let monitors = Monitor::all().unwrap();
+ let mut frame_count = 0;
+ println!("Found {} monitors", monitors.len());
+ println!("Screenshots will be saved to {}", path);
+ println!("Interval: {} seconds", interval);
+ println!("Press Ctrl+C to stop");
+ println!("{}", DISPLAY);
+
+ let (tx, rx) = channel::unbounded::<(ImageBuffer<Rgba<u8>, Vec<u8>>, String)>();
+
+ // Thread for saving images
+ let save_thread = thread::spawn(move || {
+ while let Ok((image, filename)) = rx.recv() {
+ image.save(&filename).unwrap();
+ }
+ });
+
+ while running.load(Ordering::SeqCst) {
+ let day_dir = format!("{}/{}", path, Local::now().format("%Y-%m-%d"));
+ create_dir_all(&day_dir).unwrap();
+
+ let sub_dir = format!("{}/{}", day_dir, frame_count / 60);
+ create_dir_all(&sub_dir).unwrap();
+
+ for monitor in &monitors {
+ let image = monitor.capture_image().unwrap();
+ let filename = format!(
+ "{}/monitor-{}-{}.png",
+ sub_dir,
+ normalized(monitor.name()),
+ frame_count
+ );
+ tx.send((image, filename)).unwrap();
+ }
+ println!("Captured screens. Frame: {}", frame_count);
+ sleep(Duration::from_secs_f32(interval));
+ frame_count += 1;
+ }
+ drop(tx); // Close the channel
+ save_thread.join().unwrap(); // Wait for the saving thread to finish
+}
+
+fn main() {
+ let cli = Cli::parse();
+ let running = Arc::new(AtomicBool::new(true));
+ let r = running.clone();
+
+ ctrlc::set_handler(move || {
+ r.store(false, Ordering::SeqCst);
+ })
+ .expect("Error setting Ctrl-C handler");
+
+ screenpipe(&cli.path, cli.interval, running);
+}