Skip to content

Commit

Permalink
feat(clipboard): implement clipboard integration (#91)
Browse files Browse the repository at this point in the history
* feat(clipboard): implement clipboard integration

Add the --clipboard flag and implement functionality to make image available on the clipboard using wl-clipboard-rs.

* style(format): apply code formatting to cli.rs

* feat(clipboard): implement fork wait for clipboard

Add functionality offering image on clipboard persistently in the background

* feat(clipboard): inform user about wayshot persisting in background with --clipboard

* feat(clipboard): use tracing::warn instead of print if fork fails

* feat(clipboard): Switch from the fork crate to the nix crate for daemonization

* style(format): code formatting to wayshot.rs

* style(typo): corrected a typo in the comments
  • Loading branch information
CheerfulPianissimo authored Mar 23, 2024
1 parent 9e7919e commit b9219b1
Show file tree
Hide file tree
Showing 4 changed files with 225 additions and 21 deletions.
169 changes: 164 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions wayshot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ 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"
nix = { version = "0.28.0", features = ["process"] }

[[bin]]
name = "wayshot"
path = "src/wayshot.rs"
6 changes: 5 additions & 1 deletion wayshot/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PathBuf>,

/// 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,

/// 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,
Expand Down
Loading

0 comments on commit b9219b1

Please sign in to comment.