From 5c3e220c319e9020fa71b1a2cac4df6dbf4dfcad Mon Sep 17 00:00:00 2001 From: Sooraj S <94284954+CheerfulPianissimo@users.noreply.github.com> Date: Sun, 25 Aug 2024 21:32:01 +0530 Subject: [PATCH] Update documentation with changes in freeze-feat (#116) * [docs] update manpage (1) with changes in freeze-feat * [fix] make arguments to slurp optional * [docs] update manpage(7) with cli changes * [docs] update README with new cli --- README.md | 8 +++--- docs/wayshot.1.scd | 59 ++++++++++++++++++++++++++---------------- docs/wayshot.7.scd | 16 ++++++------ wayshot/src/cli.rs | 2 +- wayshot/src/wayshot.rs | 4 +-- 5 files changed, 51 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index b0c60dbf..ced3676d 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,10 @@ NOTE: Read `man 7 wayshot` for more examples. NOTE: Read `man wayshot` for flag information. -Region Selection: +Screenshot and Crop Region: ```bash -wayshot -s "$(slurp)" +wayshot -s ``` Fullscreen: @@ -38,13 +38,13 @@ wayshot Screenshot and copy to clipboard: ```bash -wayshot --stdout | wl-copy +wayshot --clipboard ``` Pick a hex color code, using ImageMagick: ```bash -wayshot -s "$(slurp -p)" --stdout | convert - -format '%[pixel:p{0,0}]' txt:-|grep -E "#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})" -o +wayshot -s - | convert - -format '%[pixel:p{0,0}]' txt:-|grep -E "#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})" -o ``` # Installation diff --git a/docs/wayshot.1.scd b/docs/wayshot.1.scd index 47a9a8fe..65dea812 100644 --- a/docs/wayshot.1.scd +++ b/docs/wayshot.1.scd @@ -6,57 +6,70 @@ Wayshot - Screenshot tool for compositors implementing zwlr_screencopy_v1 such a # SYNOPSIS -*wayshot* [_options_] +*wayshot* [_options_] [_output_] + +# ARGUMENTS + +*output*, + Location to send captured screenshot to, it can be of the following types: + 1. A directory, image outputs will be saved in the default format "wayshot-yyyy-mm-dd-hh-mm-ss.png" + + 2. A path (Encoding is automatically inferred from the extension). + + 3. '-' which sends the screenshot to stdout. + + The *--clipboard* option can also be used simultaneously with any of the above to copy the image to the clipboard too. # OPTIONS -*-h*, *--help* - Print help message and quit. +*-h*, + Print concise help messages and quit. + +*--help*, + Print full help message and quit. *-V*, *--version* Print version information. -*-d*, *--debug* - Enable debug mode. +*--log-level * + Log level to be used for printing to stderr + Possible values: trace, debug, info, warn, error + + Default value: info *-c*, *--cursor* Enable cursor visibility in screenshots. *--clipboard* - Copy image contents to clipboard. + Copy image contents to clipboard also. + Using this flag will cause the wayshot process to fork and persist in the background offering the image + on the wayland clipboard until some other program overwrites the clipboard. *-e*, *--extension* - Set the image encoder. + Set the image encoder. Without this option, encoding is either inferred from the *output* filename or defaults to png. Valid arguments: - - jpeg - jpg - png (Default encoder) - ppm - qoi - webp -*-f*, *--file* - Set a custom file path. The default path is `./{current_unix_timestamp}-wayshot.{encoder}` - eg: 1659034753-wayshot.png - -*-l*, *--listoutputs* +*-l*, *--list-outputs* List all valid output names. This flag is generally used in combination with *-o* flag. -*--chooseoutput* +*--choose-output* Present a fuzzy selector for display (wl_output) selection. *-o*, *--output* Choose a particular display (wl_output) to screenshot. -*-s*, *--slurp* - Choose a portion of your display to screenshot using the slurp program. - https://github.com/emersion/slurp . Valid arguments have the form - "%x %y %w %h" or "%x,%y %wx%h", where for example "%w" is an integer giving - the width of the region. - -*--stdout* - Emit image data to stdout. The following flag is helpful to pipe image data - to other programs. +*-s*, *--slurp*= + If this option is passed, wayshot takes a screenshot first and then uses the *slurp* program to select a portion of that screenshot + https://github.com/emersion/slurp . SLURP_ARGS are any arguments that need to be passed to *slurp*, see *slurp(1)* for more information. + + Example: + *wayshot -s="-b 11223377"* + - This takes a screenshot then calls slurp with "-b 11223377" as an argument for cropping the screenshot. # SEE ALSO - wayshot(7) diff --git a/docs/wayshot.7.scd b/docs/wayshot.7.scd index b4a59da2..459edcc0 100644 --- a/docs/wayshot.7.scd +++ b/docs/wayshot.7.scd @@ -6,22 +6,22 @@ Wayshot - Screenshot tool for compositors implementing zwlr_screencopy_v1 such a # SYNOPSIS -*wayshot* [_options_] +*wayshot* [_options_] [_output_] # REGION SELECTION -wayshot -s "$(slurp)" +wayshot -s -# FULLSCREEN +# CAPTURE FULLSCREEN wayshot # CUSTOM FILE PATH AND EXTENSION -wayshot -f ../screenshot.png --extension ppm +wayshot ../screenshot.png --extension ppm # SCREENSHOT AND COPY TO CLIPBOARD -wayshot --stdout -e jpeg | wl-copy +wayshot --clipboard # SCREENSHOT A PARTICULAR DISPLAY @@ -30,15 +30,15 @@ wayshot -o eDP-1 # PICK A HEX COLOR CODE, USING IMAGEMAGICk -wayshot -s "$(slurp)" --stdout | convert - -format '%[pixel:p{0,0}]' txt:-|grep -E "#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})" -o +wayshot -s - | convert - -format '%[pixel:p{0,0}]' txt:-|grep -E "#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})" -o # PICK A HEX COLOR CODE WITHOUT USING IMAGEMAGICK -wayshot -s "$(slurp -p)" --stdout -e ppm | tail -c 3 | od -An -tuC | xargs printf '#%02X%02X%02X\n' +wayshot -s - --encoding ppm | tail -c 3 | od -An -tuC | xargs printf '#%02X%02X%02X\n' # PICK A COLOR, USING IMAGEMAGICK -wayshot -s "$(slurp -p)" --stdout | convert - -format '%[pixel:p{0,0}]' txt:- +wayshot -s - | convert - -format '%[pixel:p{0,0}]' txt:- # AUTHORS diff --git a/wayshot/src/cli.rs b/wayshot/src/cli.rs index 0ad61c23..9882e09d 100644 --- a/wayshot/src/cli.rs +++ b/wayshot/src/cli.rs @@ -29,7 +29,7 @@ pub struct Cli { /// Arguments to call slurp with for selecting a region #[arg(short, long, value_name = "SLURP_ARGS")] - pub slurp: Option, + pub slurp: Option>, /// Enable cursor in screenshots #[arg(short, long)] diff --git a/wayshot/src/wayshot.rs b/wayshot/src/wayshot.rs index 0930b845..73f524d7 100644 --- a/wayshot/src/wayshot.rs +++ b/wayshot/src/wayshot.rs @@ -66,8 +66,8 @@ fn main() -> Result<()> { return Ok(()); } - let image_buffer = if let Some(slurp_region) = cli.slurp { - let slurp_region = slurp_region.clone(); + let image_buffer = if let Some(slurp_args) = cli.slurp { + let slurp_region = slurp_args.unwrap_or("".to_string()); wayshot_conn.screenshot_freeze( Box::new(move || { || -> Result {