Strata/strata-daemon
edu4rdshl 805b14a0bd perf: drop unused base64 return value from make_thumbnail
make_thumbnail was computing a base64 string of the thumbnail on every
image clipboard capture. The caller only ever used the raw bytes and
immediately discarded the String. Remove the base64 encode, simplify
the return type to Result<Vec<u8>>, and drop the now-unused
'use base64::Engine' import from main.rs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-25 03:41:30 -05:00
..
src perf: drop unused base64 return value from make_thumbnail 2026-05-25 03:41:30 -05:00
Cargo.lock Initial commit 2026-05-25 03:02:34 -05:00
Cargo.toml Initial commit 2026-05-25 03:02:34 -05:00
README.md Initial commit 2026-05-25 03:02:34 -05:00

strata-daemon

The Rust backend for Strata. Speaks D-Bus, stores history in SQLite, generates image thumbnails, and indexes text for full-text search.

It is not GNOME-specific. Any D-Bus client can use it.

Build

cargo build --release
# binary at target/release/strata-daemon

The GNOME extension spawns this binary automatically; you only need to run it manually if you're using a non-GNOME front-end.

Storage

Path Contents
~/.local/share/strata/clipboard.db History DB (WAL mode, FTS5 index)
~/.cache/strata/thumbnails/<id>.png Per-item image thumbnails

D-Bus interface

  • Bus name: org.gnome.Strata
  • Object path: /org/gnome/Strata
  • Interface: org.gnome.Strata.Manager
Member Signature Notes
SubmitItem (method) (s ay) → () Ingest a clipboard payload (mime, raw bytes)
GetHistory (method) (u u) → s (offset, limit) → JSON array
SearchHistory (method) (s u) → s FTS5 query → JSON array
GetThumbnail (method) s → ay PNG bytes for item id
GetItemContent (method) s → (ss) (mime, base64) for paste-back
SetClipboard (method) s → () Re-copy a stored item
DeleteItem (method) s → ()
ClearHistory (method) () → ()
Shutdown (method) () → () Graceful exit
SetConfig (method) (uuu) → () (max_history, max_text_bytes, max_image_bytes); 0 means leave unchanged
ItemAdded (signal) (sss) (id, mime, preview)
ItemDeleted (signal) s
HistoryCleared (signal) ()

Example: drive it from the shell

# Start the daemon (foreground)
./target/release/strata-daemon

# In another terminal:
busctl --user call org.gnome.Strata /org/gnome/Strata \
       org.gnome.Strata.Manager GetHistory uu 0 10

# Submit text:
busctl --user call org.gnome.Strata /org/gnome/Strata \
       org.gnome.Strata.Manager SubmitItem say "text/plain;charset=utf-8" 5 104 101 108 108 111

# Listen for new items:
busctl --user monitor org.gnome.Strata

Supported clipboard payloads

Strict mime allowlist. Per-type size caps default to 1 MB for text and 5 MB for images; both are runtime-configurable via the SetConfig D-Bus method (the GNOME extension wires this to its GSettings).

  • Text: text/plain*, UTF8_STRING, STRING, TEXT, text/rtf, text/markdown, text/html, text/uri-list, x-special/nautilus-clipboard, application/x-kde-cutselection, application/rtf
  • Images: image/png, image/jpeg, image/jpg, image/gif, image/webp, image/bmp, image/tiff, image/avif, image/x-icon, image/svg+xml

Items carrying x-kde-passwordManagerHint are silently dropped (KeePassXC / Bitwarden convention).

Module map

src/
├── main.rs          Entry point, clipboard ingest, mime allowlist
├── config.rs        Config loading + size caps
├── db.rs            SQLite schema, FTS5, parameterised queries
├── dbus_service.rs  zbus interface implementation
└── clipboard/
    ├── monitor.rs   Optional wl-clipboard-rs monitor (unused on GNOME)
    └── writer.rs    Paste-back helpers

Tests

cargo test --release

License

GPL-3.0-or-later.