惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

有赞技术团队
有赞技术团队
美团技术团队
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
阮一峰的网络日志
阮一峰的网络日志
S
SegmentFault 最新的问题
博客园_首页
雷峰网
雷峰网
V
V2EX
The Cloudflare Blog
博客园 - 三生石上(FineUI控件)
量子位
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 聂微东
V
Visual Studio Blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
Jina AI
Jina AI
月光博客
月光博客
L
LangChain Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
scrcpy Integration in a Tauri App — Android Screen Mirror...
hiyoyo · 2026-05-24 · via DEV Community
Cover image for scrcpy Integration in a Tauri App — Android Screen Mirroring on Mac

hiyoyo

All tests run on an 8-year-old MacBook Air.
All results from shipping 7 Mac apps as a solo developer. No sponsored opinion.
HiyokoKit includes Android remote control via scrcpy. Launching and managing scrcpy from a Tauri app has specific challenges.
Here's how I handle it.

What scrcpy is
scrcpy is an open-source tool that mirrors and controls an Android device screen over ADB. It's the best free option for Android screen mirroring on Mac — fast, low latency, no app required on the device.

Launching scrcpy from Rust
rustuse std::process::{Command, Child};
use std::sync::Mutex;

pub struct ScrcpyProcess {
child: Option,
}

impl ScrcpyProcess {
pub fn start(
&mut self,
device_serial: &str,
max_size: u32,
bit_rate: &str,
) -> Result<(), AppError> {
let child = Command::new("scrcpy")
.args([
"--serial", device_serial,
"--max-size", &max_size.to_string(),
"--video-bit-rate", bit_rate,
"--window-title", "Android Mirror",
"--no-audio",
])
.spawn()
.map_err(|e| AppError::Scrcpy(e.to_string()))?;

    self.child = Some(child);
    Ok(())
}

pub fn stop(&mut self) {
    if let Some(mut child) = self.child.take() {
        child.kill().ok();
    }
}

pub fn is_running(&mut self) -> bool {
    if let Some(child) = &mut self.child {
        child.try_wait().map(|s| s.is_none()).unwrap_or(false)
    } else {
        false
    }
}

Enter fullscreen mode Exit fullscreen mode

}

Bundling scrcpy
scrcpy needs to be available on the user's machine or bundled with your app. I bundle it in app resources as a universal binary:
json{
"bundle": {
"resources": [
"bin/scrcpy",
"bin/adb"
]
}
}
At runtime, get the resource path:
rustlet scrcpy_path = app_handle
.path()
.resource_dir()
.unwrap()
.join("bin/scrcpy");

Detecting when scrcpy exits
scrcpy exits when the user closes the mirror window. Detect this to update your UI:
rust// Poll in background
tokio::spawn(async move {
loop {
tokio::time::sleep(Duration::from_secs(1)).await;

    let running = {
        let mut proc = scrcpy_state.lock().unwrap();
        proc.is_running()
    };

    if !running {
        app_handle.emit("scrcpy-stopped", ()).ok();
        break;
    }
}

Enter fullscreen mode Exit fullscreen mode

});

Multiple device support
scrcpy's --serial flag selects a specific device when multiple are connected. Get the serial from adb devices and pass it explicitly:
rustasync fn get_device_serial() -> Result {
let output = Command::new("adb")
.args(["devices"])
.output()
.await?;

let stdout = String::from_utf8_lossy(&output.stdout);
stdout.lines()
    .skip(1)
    .find(|l| l.contains("device"))
    .and_then(|l| l.split_whitespace().next())
    .map(|s| s.to_string())
    .ok_or(AppError::Device("No device found".into()))

Enter fullscreen mode Exit fullscreen mode

}

If this was useful, a ❤️ helps more than you'd think — thanks!
Hiyoko PDF Vault → https://hiyokomtp.lemonsqueezy.com/checkout
X → @hiyoyok