Add image clipboard backend on Linux
This commit is contained in:
parent
89d0bd8596
commit
f884ade3ff
|
@ -19,7 +19,8 @@
|
|||
|
||||
use std::process::{Command, Stdio};
|
||||
use std::io::{Write};
|
||||
use log::error;
|
||||
use log::{error, warn};
|
||||
use std::path::Path;
|
||||
|
||||
pub struct LinuxClipboardManager {}
|
||||
|
||||
|
@ -63,6 +64,29 @@ impl super::ClipboardManager for LinuxClipboardManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn set_clipboard_image(&self, image_path: &Path) {
|
||||
let extension = image_path.extension();
|
||||
let mime = match extension {
|
||||
Some(ext) => {
|
||||
let ext = ext.to_string_lossy().to_lowercase();
|
||||
match ext.as_ref() {
|
||||
"png" => {"image/png"},
|
||||
"jpg" | "jpeg" => {"image/jpeg"},
|
||||
"gif" => {"image/gif"},
|
||||
"svg" => {"image/svg"},
|
||||
_ => {"image/png"},
|
||||
}
|
||||
},
|
||||
None => {"image/png"},
|
||||
};
|
||||
|
||||
let image_path = image_path.to_string_lossy().into_owned();
|
||||
|
||||
let res = Command::new("xclip")
|
||||
.args(&["-selection", "clipboard", "-t", mime, "-i", &image_path])
|
||||
.spawn();
|
||||
}
|
||||
}
|
||||
|
||||
impl LinuxClipboardManager {
|
||||
|
|
Loading…
Reference in New Issue
Block a user