mirror of
https://github.com/edu4rdshl/Strata.git
synced 2026-07-17 23:24:46 +00:00
Audit fixes for the daemon:
- Decode gif/webp/bmp/tiff/ico (enable the pure-Rust image features). These
mimes were accepted by pick_mime but the image crate only had png/jpeg, so
thumbnail decode failed and the item was silently dropped. Drop avif (needs
heavy C deps) and svg (not a raster format the image crate decodes) from the
allowlist so unsupported types are never selected.
- ItemAdded signal preview now uses db::PREVIEW_CHARS (200), matching the
history/search queries, so a just-copied row and the same row after a reload
carry identical text.
- Add a deterministic ", rowid DESC" tiebreaker to the three created_at DESC
orderings (history, search, prune) so items sharing a millisecond have a
stable order and prune can't evict the wrong one at the boundary.
- SetConfig now prunes immediately (and emits ItemDeleted) when max_history is
lowered, instead of waiting for the next copy.
- Request the bus name with AllowReplacement (plus ReplaceExisting) so a
reload's new instance can cleanly take the name; fix the misleading comment.
- Wayland monitor clears its pending-offers map on Selection{None} so it can't
grow across copy-then-clear cycles (wlroots path).
- Document that SubmitItem is a trusted-caller method (the password-manager
hint is enforced client-side; forwarding it is a future contract change).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
||
|---|---|---|
| .. | ||
| src | ||
| Cargo.lock | ||
| Cargo.toml | ||
| README.md | ||
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.