diff --git a/espanso-clipboard/src/cocoa/mod.rs b/espanso-clipboard/src/cocoa/mod.rs index 3add22e..d842592 100644 --- a/espanso-clipboard/src/cocoa/mod.rs +++ b/espanso-clipboard/src/cocoa/mod.rs @@ -19,7 +19,10 @@ mod ffi; -use std::{ffi::{CStr, CString}, path::PathBuf}; +use std::{ + ffi::{CStr, CString}, + path::PathBuf, +}; use crate::Clipboard; use anyhow::Result; diff --git a/espanso-clipboard/src/lib.rs b/espanso-clipboard/src/lib.rs index efa1adf..077728b 100644 --- a/espanso-clipboard/src/lib.rs +++ b/espanso-clipboard/src/lib.rs @@ -81,15 +81,17 @@ pub fn get_clipboard(_: ClipboardOptions) -> Result> { #[cfg(target_os = "linux")] #[cfg(feature = "wayland")] pub fn get_clipboard(options: ClipboardOptions) -> Result> { - // TODO: On some Wayland compositors (currently sway), the "wlr-data-control" protocol + // TODO: On some Wayland compositors (currently sway), the "wlr-data-control" protocol // could enable the use of a much more efficient implementation relying on the "wl-clipboard-rs" crate. // Useful links: https://github.com/YaLTeR/wl-clipboard-rs/issues/8 // - // We could even decide the correct implementation at runtime by checking if the + // We could even decide the correct implementation at runtime by checking if the // required protocol is available, if so use the efficient implementation // instead of the fallback one, which calls the wl-copy and wl-paste binaries, and is thus - // less efficient + // less efficient info!("using WaylandFallbackClipboard"); - Ok(Box::new(wayland::fallback::WaylandFallbackClipboard::new(options)?)) -} \ No newline at end of file + Ok(Box::new(wayland::fallback::WaylandFallbackClipboard::new( + options, + )?)) +} diff --git a/espanso-clipboard/src/wayland/fallback/mod.rs b/espanso-clipboard/src/wayland/fallback/mod.rs index f4793a3..157bdd5 100644 --- a/espanso-clipboard/src/wayland/fallback/mod.rs +++ b/espanso-clipboard/src/wayland/fallback/mod.rs @@ -122,21 +122,31 @@ impl Clipboard for WaylandFallbackClipboard { let mut data = Vec::new(); file.read_to_end(&mut data)?; - self.invoke_command_with_timeout(&mut Command::new("wl-copy").arg("--type").arg("image/png"), &data, "wl-copy") + self.invoke_command_with_timeout( + &mut Command::new("wl-copy").arg("--type").arg("image/png"), + &data, + "wl-copy", + ) } fn set_html(&self, html: &str, _fallback_text: Option<&str>) -> anyhow::Result<()> { - self.invoke_command_with_timeout(&mut Command::new("wl-copy").arg("--type").arg("text/html"), html.as_bytes(), "wl-copy") + self.invoke_command_with_timeout( + &mut Command::new("wl-copy").arg("--type").arg("text/html"), + html.as_bytes(), + "wl-copy", + ) } } impl WaylandFallbackClipboard { - fn invoke_command_with_timeout(&self, command: &mut Command, data: &[u8], name: &str) -> Result<()> { + fn invoke_command_with_timeout( + &self, + command: &mut Command, + data: &[u8], + name: &str, + ) -> Result<()> { let timeout = std::time::Duration::from_millis(self.command_timeout); - match command - .stdin(Stdio::piped()) - .spawn() - { + match command.stdin(Stdio::piped()).spawn() { Ok(mut child) => { if let Some(stdin) = child.stdin.as_mut() { stdin.write_all(data)?; diff --git a/espanso-clipboard/src/wayland/mod.rs b/espanso-clipboard/src/wayland/mod.rs index 9a99bf1..68603c4 100644 --- a/espanso-clipboard/src/wayland/mod.rs +++ b/espanso-clipboard/src/wayland/mod.rs @@ -17,4 +17,4 @@ * along with espanso. If not, see . */ -pub(crate) mod fallback; \ No newline at end of file +pub(crate) mod fallback; diff --git a/espanso-clipboard/src/x11/mod.rs b/espanso-clipboard/src/x11/mod.rs index 6b27c57..cccb648 100644 --- a/espanso-clipboard/src/x11/mod.rs +++ b/espanso-clipboard/src/x11/mod.rs @@ -17,4 +17,4 @@ * along with espanso. If not, see . */ -pub(crate) mod native; \ No newline at end of file +pub(crate) mod native; diff --git a/espanso-clipboard/src/x11/native/mod.rs b/espanso-clipboard/src/x11/native/mod.rs index 5bbfbf0..de5a1f1 100644 --- a/espanso-clipboard/src/x11/native/mod.rs +++ b/espanso-clipboard/src/x11/native/mod.rs @@ -17,7 +17,11 @@ * along with espanso. If not, see . */ -use std::{ffi::{CStr, CString}, io::Read, path::PathBuf}; +use std::{ + ffi::{CStr, CString}, + io::Read, + path::PathBuf, +}; use crate::Clipboard; use anyhow::Result; @@ -67,9 +71,7 @@ impl Clipboard for X11NativeClipboard { let mut data = Vec::new(); file.read_to_end(&mut data)?; - let native_result = unsafe { - ffi::clipboard_x11_set_image(data.as_ptr(), data.len() as i32) - }; + let native_result = unsafe { ffi::clipboard_x11_set_image(data.as_ptr(), data.len() as i32) }; if native_result > 0 { Ok(())