From 57068442a4f45f94e8f208315a70a3a3a420b29a Mon Sep 17 00:00:00 2001 From: CheerfulPianissimo Date: Wed, 28 Feb 2024 22:09:22 +0530 Subject: [PATCH 1/8] feat(clipboard): implement clipboard integration Add the --clipboard flag and implement functionality to make image available on the clipboard using wl-clipboard-rs. --- Cargo.lock | 146 ++++++++++++++++++++++++++++++++++++++++- wayshot/Cargo.toml | 2 + wayshot/src/cli.rs | 8 ++- wayshot/src/wayshot.rs | 48 +++++++++----- 4 files changed, 184 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9244fa4d..56f0da74 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,6 +74,12 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +[[package]] +name = "bytecount" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1e5f035d16fc623ae5f74981db80a439803888314e3a555fd6f04acd51a3205" + [[package]] name = "bytemuck" version = "1.14.0" @@ -132,7 +138,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.41", ] [[package]] @@ -175,6 +181,17 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "derive-new" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3418329ca0ad70234b9735dc4ceed10af4df60eff9c8e7b06cb5e520d92c3535" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "dialoguer" version = "0.11.0" @@ -210,6 +227,12 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "errno" version = "0.3.8" @@ -245,6 +268,12 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + [[package]] name = "flate2" version = "1.0.28" @@ -255,6 +284,12 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "fuzzy-matcher" version = "0.3.7" @@ -264,6 +299,12 @@ dependencies = [ "thread_local", ] +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" + [[package]] name = "heck" version = "0.4.1" @@ -292,6 +333,16 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" +[[package]] +name = "indexmap" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177" +dependencies = [ + "equivalent", + "hashbrown", +] + [[package]] name = "jpeg-decoder" version = "0.3.0" @@ -370,6 +421,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.7.1" @@ -390,6 +447,7 @@ dependencies = [ "cfg-if", "libc", "memoffset", + "pin-utils", ] [[package]] @@ -403,6 +461,16 @@ dependencies = [ "libc", ] +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -449,18 +517,44 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "os_pipe" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57119c3b893986491ec9aa85056780d3a0f3cf4da7cc09dd3650dbd6c6738fb9" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "overload" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +[[package]] +name = "petgraph" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +dependencies = [ + "fixedbitset", + "indexmap", +] + [[package]] name = "pin-project-lite" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "pkg-config" version = "0.3.27" @@ -577,6 +671,17 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.41" @@ -618,7 +723,7 @@ checksum = "01742297787513b79cf8e29d1056ede1313e2420b7b3b15d0a768b4921f549df" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.41", ] [[package]] @@ -650,7 +755,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.41", ] [[package]] @@ -688,6 +793,20 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "tree_magic_mini" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91adfd0607cacf6e4babdb870e9bec4037c1c4b151cfd279ccefc5e0c7feaa6d" +dependencies = [ + "bytecount", + "fnv", + "lazy_static", + "nom", + "once_cell", + "petgraph", +] + [[package]] name = "unicode-ident" version = "1.0.12" @@ -797,6 +916,7 @@ dependencies = [ "libwayshot", "tracing", "tracing-subscriber", + "wl-clipboard-rs", ] [[package]] @@ -1019,6 +1139,26 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +[[package]] +name = "wl-clipboard-rs" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57af79e973eadf08627115c73847392e6b766856ab8e3844a59245354b23d2fa" +dependencies = [ + "derive-new", + "libc", + "log", + "nix 0.26.4", + "os_pipe", + "tempfile", + "thiserror", + "tree_magic_mini", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-protocols-wlr", +] + [[package]] name = "zeroize" version = "1.7.0" diff --git a/wayshot/Cargo.toml b/wayshot/Cargo.toml index 4594d0b4..52cd2321 100644 --- a/wayshot/Cargo.toml +++ b/wayshot/Cargo.toml @@ -33,6 +33,8 @@ image = { version = "0.24", default-features = false, features = [ dialoguer = { version = "0.11.0", features = ["fuzzy-select"] } eyre = "0.6.8" +wl-clipboard-rs = "0.8.0" + [[bin]] name = "wayshot" path = "src/wayshot.rs" diff --git a/wayshot/src/cli.rs b/wayshot/src/cli.rs index 418ac8d8..e0ebd284 100644 --- a/wayshot/src/cli.rs +++ b/wayshot/src/cli.rs @@ -11,10 +11,14 @@ use clap::builder::TypedValueParser; #[derive(Parser)] #[command(version, about)] pub struct Cli { - /// Where to save the screenshot, "-" for stdout. Defaults to "$UNIX_TIMESTAMP-wayshot.$EXTENSION". + /// Where to save the screenshot, "-" for stdout. Defaults to "$UNIX_TIMESTAMP-wayshot.$EXTENSION" unless --clipboard is present. #[arg(value_name = "OUTPUT")] pub file: Option, - + + /// Copy image to clipboard along with [OUTPUT] or stdout + #[arg(long)] + pub clipboard: bool, + /// Log level to be used for printing to stderr #[arg(long, default_value = "info", value_parser = clap::builder::PossibleValuesParser::new(["trace", "debug", "info", "warn", "error"]).map(|s| -> tracing::Level{ s.parse().wrap_err_with(|| format!("Failed to parse log level: {}", s)).unwrap()}))] pub log_level: tracing::Level, diff --git a/wayshot/src/wayshot.rs b/wayshot/src/wayshot.rs index 37152a79..41c4a3af 100644 --- a/wayshot/src/wayshot.rs +++ b/wayshot/src/wayshot.rs @@ -13,6 +13,8 @@ mod utils; use dialoguer::{theme::ColorfulTheme, FuzzySelect}; use utils::EncodingFormat; +use wl_clipboard_rs::copy::{MimeType, Options, Source}; + fn select_ouput(ouputs: &[T]) -> Option where T: ToString, @@ -52,17 +54,6 @@ fn main() -> Result<()> { } } - let file = match cli.file { - Some(pathbuf) => { - if pathbuf.to_string_lossy() == "-" { - None - } else { - Some(pathbuf) - } - } - None => Some(utils::get_default_file_name(requested_encoding)), - }; - let wayshot_conn = WayshotConnection::new()?; if cli.list_outputs { @@ -111,16 +102,43 @@ fn main() -> Result<()> { wayshot_conn.screenshot_all(cli.cursor)? }; + let mut stdout_print = false; + let file = match cli.file { + Some(pathbuf) => { + if pathbuf.to_string_lossy() == "-" { + stdout_print = true; + None + } else { + Some(pathbuf) + } + } + None => { + if cli.clipboard { + None + } else { + Some(utils::get_default_file_name(requested_encoding)) + } + } + }; + if let Some(file) = file { image_buffer.save(file)?; } else { - let stdout = stdout(); let mut buffer = Cursor::new(Vec::new()); - - let mut writer = BufWriter::new(stdout.lock()); image_buffer.write_to(&mut buffer, requested_encoding)?; - writer.write_all(buffer.get_ref())?; + if stdout_print { + let stdout = stdout(); + let mut writer = BufWriter::new(stdout.lock()); + writer.write_all(buffer.get_ref())?; + } + if cli.clipboard { + let opts = Options::new(); + opts.copy( + Source::Bytes(buffer.into_inner().into()), + MimeType::Autodetect, + )?; + } } Ok(()) From c3288ea04fcb973b61c2b17281d6a4c1332c034a Mon Sep 17 00:00:00 2001 From: CheerfulPianissimo Date: Wed, 28 Feb 2024 23:33:05 +0530 Subject: [PATCH 2/8] style(format): apply code formatting to cli.rs --- wayshot/src/cli.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wayshot/src/cli.rs b/wayshot/src/cli.rs index e0ebd284..18f45264 100644 --- a/wayshot/src/cli.rs +++ b/wayshot/src/cli.rs @@ -14,11 +14,11 @@ pub struct Cli { /// Where to save the screenshot, "-" for stdout. Defaults to "$UNIX_TIMESTAMP-wayshot.$EXTENSION" unless --clipboard is present. #[arg(value_name = "OUTPUT")] pub file: Option, - + /// Copy image to clipboard along with [OUTPUT] or stdout #[arg(long)] pub clipboard: bool, - + /// Log level to be used for printing to stderr #[arg(long, default_value = "info", value_parser = clap::builder::PossibleValuesParser::new(["trace", "debug", "info", "warn", "error"]).map(|s| -> tracing::Level{ s.parse().wrap_err_with(|| format!("Failed to parse log level: {}", s)).unwrap()}))] pub log_level: tracing::Level, From f0f6d0536296fb707a6d26aa59cce8a979474188 Mon Sep 17 00:00:00 2001 From: CheerfulPianissimo Date: Sun, 3 Mar 2024 20:21:02 +0530 Subject: [PATCH 3/8] feat(clipboard): implement fork wait for clipboard Add functionality offering image on clipboard persistently in the background --- Cargo.lock | 10 ++++++++++ wayshot/Cargo.toml | 1 + wayshot/src/wayshot.rs | 29 ++++++++++++++++++++++++----- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 56f0da74..a15fd2c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -290,6 +290,15 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "fork" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60e74d3423998a57e9d906e49252fb79eb4a04d5cdfe188fb1b7ff9fc076a8ed" +dependencies = [ + "libc", +] + [[package]] name = "fuzzy-matcher" version = "0.3.7" @@ -912,6 +921,7 @@ dependencies = [ "dialoguer", "eyre", "flate2", + "fork", "image", "libwayshot", "tracing", diff --git a/wayshot/Cargo.toml b/wayshot/Cargo.toml index 52cd2321..222d49b6 100644 --- a/wayshot/Cargo.toml +++ b/wayshot/Cargo.toml @@ -34,6 +34,7 @@ dialoguer = { version = "0.11.0", features = ["fuzzy-select"] } eyre = "0.6.8" wl-clipboard-rs = "0.8.0" +fork = "0.1.23" [[bin]] name = "wayshot" diff --git a/wayshot/src/wayshot.rs b/wayshot/src/wayshot.rs index 41c4a3af..65f55321 100644 --- a/wayshot/src/wayshot.rs +++ b/wayshot/src/wayshot.rs @@ -15,6 +15,8 @@ use utils::EncodingFormat; use wl_clipboard_rs::copy::{MimeType, Options, Source}; +use fork::{fork, Fork}; + fn select_ouput(ouputs: &[T]) -> Option where T: ToString, @@ -133,11 +135,28 @@ fn main() -> Result<()> { writer.write_all(buffer.get_ref())?; } if cli.clipboard { - let opts = Options::new(); - opts.copy( - Source::Bytes(buffer.into_inner().into()), - MimeType::Autodetect, - )?; + let mut opts = Options::new(); + match fork() { + // Having the image persistently available on the clipboard requires a wayshot process to be alive. + // Fork the process with a child detached from the main process and have the parent exit + Ok(Fork::Parent(_)) => { + return Ok(()); + } + Ok(Fork::Child) => { + opts.foreground(true); //Offer the image till somthing else is available on the clipboard + opts.copy( + Source::Bytes(buffer.into_inner().into()), + MimeType::Autodetect, + )?; + } + Err(e) => { + println!("Fork failed with error: {e}, couldn't offer image on the clipboard persistently. Use a clipboard manager."); + opts.copy( + Source::Bytes(buffer.into_inner().into()), + MimeType::Autodetect, + )?; + } + } } } From be35e61227ad4c6264cf9c137f3a9490e35c3e0c Mon Sep 17 00:00:00 2001 From: CheerfulPianissimo Date: Tue, 5 Mar 2024 12:54:47 +0530 Subject: [PATCH 4/8] feat(clipboard): inform user about wayshot persisting in background with --clipboard --- wayshot/src/cli.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wayshot/src/cli.rs b/wayshot/src/cli.rs index 18f45264..71083fac 100644 --- a/wayshot/src/cli.rs +++ b/wayshot/src/cli.rs @@ -15,7 +15,7 @@ pub struct Cli { #[arg(value_name = "OUTPUT")] pub file: Option, - /// Copy image to clipboard along with [OUTPUT] or stdout + /// Copy image to clipboard along with [OUTPUT] or stdout. wayshot persists in the background to offer the image till the clipboard is overwritten. #[arg(long)] pub clipboard: bool, From 9608b101a18d2e82f2df8b3b792d9970c2c00bbf Mon Sep 17 00:00:00 2001 From: CheerfulPianissimo Date: Tue, 5 Mar 2024 13:47:37 +0530 Subject: [PATCH 5/8] feat(clipboard): use tracing::warn instead of print if fork fails --- wayshot/src/wayshot.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wayshot/src/wayshot.rs b/wayshot/src/wayshot.rs index 65f55321..6f5683ab 100644 --- a/wayshot/src/wayshot.rs +++ b/wayshot/src/wayshot.rs @@ -150,7 +150,8 @@ fn main() -> Result<()> { )?; } Err(e) => { - println!("Fork failed with error: {e}, couldn't offer image on the clipboard persistently. Use a clipboard manager."); + tracing::warn!("Fork failed with error: {e}, couldn't offer image on the clipboard persistently. + Use a clipboard manager to record screenshot."); opts.copy( Source::Bytes(buffer.into_inner().into()), MimeType::Autodetect, From c2a12906104bb60dd0f3d9005975035604213763 Mon Sep 17 00:00:00 2001 From: CheerfulPianissimo Date: Tue, 19 Mar 2024 10:38:10 +0530 Subject: [PATCH 6/8] feat(clipboard): Switch from the fork crate to the nix crate for daemonization --- Cargo.lock | 33 +++++++++++++++++++++------------ wayshot/Cargo.toml | 2 +- wayshot/src/wayshot.rs | 8 ++++---- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a15fd2c2..ac5fa153 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -107,6 +107,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + [[package]] name = "clap" version = "4.4.18" @@ -290,15 +296,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "fork" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60e74d3423998a57e9d906e49252fb79eb4a04d5cdfe188fb1b7ff9fc076a8ed" -dependencies = [ - "libc", -] - [[package]] name = "fuzzy-matcher" version = "0.3.7" @@ -366,9 +363,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.151" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libloading" @@ -470,6 +467,18 @@ dependencies = [ "libc", ] +[[package]] +name = "nix" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" +dependencies = [ + "bitflags 2.4.1", + "cfg-if", + "cfg_aliases", + "libc", +] + [[package]] name = "nom" version = "7.1.3" @@ -921,9 +930,9 @@ dependencies = [ "dialoguer", "eyre", "flate2", - "fork", "image", "libwayshot", + "nix 0.28.0", "tracing", "tracing-subscriber", "wl-clipboard-rs", diff --git a/wayshot/Cargo.toml b/wayshot/Cargo.toml index 222d49b6..9364ff88 100644 --- a/wayshot/Cargo.toml +++ b/wayshot/Cargo.toml @@ -34,7 +34,7 @@ dialoguer = { version = "0.11.0", features = ["fuzzy-select"] } eyre = "0.6.8" wl-clipboard-rs = "0.8.0" -fork = "0.1.23" +nix = { version = "0.28.0", features = ["process"] } [[bin]] name = "wayshot" diff --git a/wayshot/src/wayshot.rs b/wayshot/src/wayshot.rs index 6f5683ab..b17c0b52 100644 --- a/wayshot/src/wayshot.rs +++ b/wayshot/src/wayshot.rs @@ -15,7 +15,7 @@ use utils::EncodingFormat; use wl_clipboard_rs::copy::{MimeType, Options, Source}; -use fork::{fork, Fork}; +use nix::unistd::{fork, ForkResult}; fn select_ouput(ouputs: &[T]) -> Option where @@ -136,13 +136,13 @@ fn main() -> Result<()> { } if cli.clipboard { let mut opts = Options::new(); - match fork() { + match unsafe { fork() } { // Having the image persistently available on the clipboard requires a wayshot process to be alive. // Fork the process with a child detached from the main process and have the parent exit - Ok(Fork::Parent(_)) => { + Ok(ForkResult::Parent{..}) => { return Ok(()); } - Ok(Fork::Child) => { + Ok(ForkResult::Child) => { opts.foreground(true); //Offer the image till somthing else is available on the clipboard opts.copy( Source::Bytes(buffer.into_inner().into()), From 94d6e2e96926b5abed33c1a7ed9438b2340d6185 Mon Sep 17 00:00:00 2001 From: CheerfulPianissimo Date: Tue, 19 Mar 2024 10:43:25 +0530 Subject: [PATCH 7/8] style(format): code formatting to wayshot.rs --- wayshot/src/wayshot.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wayshot/src/wayshot.rs b/wayshot/src/wayshot.rs index b17c0b52..9fac733b 100644 --- a/wayshot/src/wayshot.rs +++ b/wayshot/src/wayshot.rs @@ -139,7 +139,7 @@ fn main() -> Result<()> { match unsafe { fork() } { // Having the image persistently available on the clipboard requires a wayshot process to be alive. // Fork the process with a child detached from the main process and have the parent exit - Ok(ForkResult::Parent{..}) => { + Ok(ForkResult::Parent { .. }) => { return Ok(()); } Ok(ForkResult::Child) => { From 482a8394e77ad5cf642782756414c31db2daa654 Mon Sep 17 00:00:00 2001 From: CheerfulPianissimo Date: Tue, 19 Mar 2024 22:06:11 +0530 Subject: [PATCH 8/8] style(typo): corrected a typo in the comments --- wayshot/src/wayshot.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wayshot/src/wayshot.rs b/wayshot/src/wayshot.rs index 9fac733b..a1c8ac0d 100644 --- a/wayshot/src/wayshot.rs +++ b/wayshot/src/wayshot.rs @@ -143,7 +143,7 @@ fn main() -> Result<()> { return Ok(()); } Ok(ForkResult::Child) => { - opts.foreground(true); //Offer the image till somthing else is available on the clipboard + opts.foreground(true); // Offer the image till something else is available on the clipboard opts.copy( Source::Bytes(buffer.into_inner().into()), MimeType::Autodetect,