raw img + background png convert
This commit is contained in:
@ -1,10 +1,14 @@
|
||||
use crate::{database::Database, models::ClipboardEntry};
|
||||
use arboard::Clipboard;
|
||||
use std::time::Duration;
|
||||
use std::{error::Error, sync::mpsc::channel};
|
||||
use std::{
|
||||
error::Error,
|
||||
sync::mpsc::channel,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
use wayland_clipboard_listener::{WlClipboardPasteStream, WlListenType};
|
||||
|
||||
pub fn start(db: Database, mut clipboard: Clipboard) -> Result<(), Box<dyn Error>> {
|
||||
pub fn start(db: Arc<Mutex<Database>>, mut clipboard: Clipboard) -> Result<(), Box<dyn Error>> {
|
||||
let (tx, rx) = channel();
|
||||
|
||||
std::thread::spawn(
|
||||
@ -26,18 +30,24 @@ pub fn start(db: Database, mut clipboard: Clipboard) -> Result<(), Box<dyn Error
|
||||
|
||||
for _ in rx {
|
||||
println!("Clipboard update!");
|
||||
// if let Ok(entry) = ClipboardEntry::new(&mut clipboard) {
|
||||
// if let Err(e) = db.append(entry) {
|
||||
// eprintln!("SQLite writing error: {}", e);
|
||||
// } else {
|
||||
// println!("SQLite edited!");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
match ClipboardEntry::new(&mut clipboard) {
|
||||
Ok(entry) => db.append(entry)?,
|
||||
Err(e) => eprintln!("{}", e),
|
||||
if let Ok(entry) = ClipboardEntry::new(&mut clipboard) {
|
||||
let db_clone = Arc::clone(&db);
|
||||
|
||||
std::thread::spawn(move || {
|
||||
let db_lock = db_clone.lock().unwrap();
|
||||
|
||||
if let Err(e) = db_lock.append(entry) {
|
||||
eprintln!("SQLite writing error: {}", e);
|
||||
} else {
|
||||
println!("SQLite edited!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// match ClipboardEntry::new(&mut clipboard) {
|
||||
// Ok(entry) => db.append(entry)?,
|
||||
// Err(e) => eprintln!("{}", e),
|
||||
// }
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user