stash: don't initialize watch daemon with None

Fixes the daemon always updating the latest entry.

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I6a6a696489a2e9a0928ff799a4210c160014c485
This commit is contained in:
raf 2025-08-12 21:47:03 +03:00
commit 5bcc23b6f9
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF

View file

@ -101,7 +101,22 @@ fn report_error<T>(result: Result<T, impl std::fmt::Display>, context: &str) ->
async fn run_daemon(db: &db::SqliteClipboardDb, max_dedupe_search: u64, max_items: u64) { async fn run_daemon(db: &db::SqliteClipboardDb, max_dedupe_search: u64, max_items: u64) {
log::info!("Starting clipboard watch daemon"); log::info!("Starting clipboard watch daemon");
let mut last_contents: Option<Vec<u8>> = None; // Initialize with current clipboard to avoid duplicating on startup
let mut last_contents: Option<Vec<u8>> = match get_contents(
ClipboardType::Regular,
Seat::Unspecified,
wl_clipboard_rs::paste::MimeType::Any,
) {
Ok((mut reader, _)) => {
let mut buf = Vec::new();
if reader.read_to_end(&mut buf).is_ok() && !buf.is_empty() {
Some(buf)
} else {
None
}
}
Err(_) => None,
};
loop { loop {
match get_contents( match get_contents(