HTTP screen snapshot service for the local desktop (KDE Wayland)
# Arch
sudo pacman -S pipewire libjpeg-turbo libwebp libpng
# Debian / Ubuntu
sudo apt install libpipewire-0.3-dev libjpeg-dev libwebp-dev libpng-devmoon build --target native --release cmd/main cmd/tray cmd/portal
./install.sh --startWAYLAND_DISPLAY=wayland-1 "$(bash -c '. scripts/lib.sh; sk_exe . release cmd/main')" --port 8930| 路径 | 返回 |
|---|---|
| GET /snapshot.jpg | 当前画面,原分辨率 |
| GET /snapshot-1280.jpg | 缩到宽 1280 |
| GET /snapshot-1280.webp | 同样尺寸,体积更小 |
| GET /health | 采集状态 JSON,含帧龄、耗时、失败计数、取帧来源 |
| GET /skill.md | 完整用法 |
| GET /llms.txt | 给模型看的端点索引 |
import "conglinyizhi/screen-kacha/moonpipewire" @pipewire
import "conglinyizhi/screen-kacha/moonimage" @imagelink: { "native": { "cc-link-flags": "-lpipewire-0.3" } }pub enum FrameSource {
Pipewire
Spectacle
Fake
}pub struct PipeWireState {
fails : Int
stream : PipeWire
raw_seq : Int
raw_frame : (String, Int, Int)?
raw_prev : String?
}fn PumpClocks::observe(self : PumpClocks, push : Bool, seq : Int64, streaming : Bool, now_ms : Int64) -> (Int64, Int64)pub struct Region {
x : Double
y : Double
w : Double
h : Double
}pub struct Store {
shot : String
lock : Mutex
fake : String?
wl_dir : String
pw_state : PipeWireState
src : FrameSource
dead_rounds : Int
last_req : Int64
frame : Frame?
cap_ms : Int64
count : Int
fails : Int
consec_fails : Int
last_capture : Int64
pump_ms : Int
err : String
seq : Int
cursor_fails : Int
cursor_err : String
missing_docs : Map[String, Bool]
data_dir : String
embedded : Map[String, Bytes]
asset_dir : String
tmp_dir : String
}async fn Store::watchdog(self : Store, frame_age_ms : Int64, since_streaming_ms : Int64, recover : async () -> Int?) -> WatchdogOutcomepub struct StreamClock {
seq : Int64
since_ms : Int64
}pub struct StreamStateClock {
since_ms : Int64
}let PUSH_STALE_MS : Int64let STREAM_GRACE_MS : Int64let STREAM_STATE_STREAMING : Intlet TRAY_MISS_DEAD : Intlet TRAY_PROBE_BASE_MS : Intfn acquire_instance_lock(dir : String) -> Boolfn backoff_wait_ms(base_ms : Int, consec : Int) -> Int| 连续失败 | 倍数 | 等待 |
|---|---|---|
| 0(正常) | 1× | 500ms |
| 1 | 1× | 500ms |
| 2 | 2× | 1s |
| 3 | 4× | 2s |
| 4 | 8× | 4s |
| 5 | 16× | 8s |
| 6 | 32× | 16s |
| 7 及以上 | 封顶 | 30s |
fn capture_too_soon(last_capture_ms : Int64, now_ms : Int64) -> Boolfn clean_stale_frames(dir : String, prefix : String, suffix : String) -> Intfn config_line_key(line : String) -> String?fn decide_probe(miss_count : Int, pressure : Bool, stale_ms : Int64, base_ms : Int) -> ProbeDecisionfn fill_port(text : String, port : Int) -> Stringfn frame_is_stalled(frame_age_ms : Int64, idle_ms : Int64, pump_ms : Int) -> Boolfn host_allowed(host : String) -> Boolfn is_cgnat(ip : String) -> Boolfn is_lan(ip : String) -> Boolfn judge_frame_flow(src : FrameSource, frame_age_ms : Int64, stale_ms : Int64, stream_state : Int, since_streaming_ms : Int64) -> FrameFlowfn normalize_path(raw : String) -> Stringfn parse_cursor_pos_text(text : String) -> (Int, Int)?fn parse_flag_value(v : String) -> Boolfn parse_load1(text : String) -> Int?fn parse_psi_some_avg10(text : String) -> Int?fn portal_wait_rounds(orphaned : Bool, helper_alive : Bool) -> Intfn pressure_is_high(cpu_avg10 : Int?, io_avg10 : Int?, load1 : Int?, ncpu : Int) -> Boolfn process_tail(text : String) -> Stringasync fn read_cursor_pos(path : String) -> (Int, Int)?fn reject_slots(max_conns : Int) -> Intfn reject_timeout_ms() -> Intfn runtime_dir_from(env : String?, uid : Int) -> Stringasync fn serve_with_access(router : Router, mcp : McpEndpoint, server : Server, access : Access, max_conns : Int) -> Unitfn spectacle_fail_msg(code : Int, why : String) -> Stringfn stale_ms_of(now_ms : Int64, ts_ms : Int64) -> Int64fn stall_reason(frame_age_ms : Int64, stale_ms : Int64, stream_state : Int, since_streaming_ms : Int64) -> Stringasync fn supervise_tray() -> Unitfn tray_miss_path() -> String?fn unmap_ipv4(ip : String) -> Stringfn wants_html(accept : String?) -> BoolInstall
Download zipHTTP screen snapshot service for the local desktop (KDE Wayland)