Skip to content

Commit

Permalink
Merge pull request #15 from erlingrj/copy-to-clipboard
Browse files Browse the repository at this point in the history
Add option to copy the snapshot'ed image to the clipboard
  • Loading branch information
cloudsftp committed Oct 5, 2023
2 parents 56c5449 + 3bf9819 commit 0dd6089
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion reSnap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ display_output_file="${RESNAP_DISPLAY:-true}"
color_correction="${RESNAP_COLOR_CORRECTION:-true}"
byte_correction="${RESNAP_BYTE_CORRECTION:-true}"
filters="null"
copy_to_clipboard="false"
construct_sketch="false"

# parsing arguments
while [ $# -gt 0 ]; do
Expand Down Expand Up @@ -43,6 +45,14 @@ while [ $# -gt 0 ]; do
display_output_file="false"
shift
;;
-x | --clipboard)
copy_to_clipboard="true"
shift
;;
-f | --sketch)
construct_sketch="true"
shift
;;
-c | --og-color)
color_correction="false"
shift
Expand All @@ -56,7 +66,7 @@ while [ $# -gt 0 ]; do
exit 0
;;
-h | --help | *)
echo "Usage: $0 [-l] [-d] [-n] [-v] [--source <ssh-host>] [--output <output-file>] [-h]"
echo "Usage: $0 [-l] [-d] [-n] [-v] [-x] [--source <ssh-host>] [--output <output-file>] [-h]"
echo "Examples:"
echo " $0 # snapshot in portrait"
echo " $0 -l # snapshot in landscape"
Expand All @@ -65,8 +75,10 @@ while [ $# -gt 0 ]; do
echo " $0 -d # display the file"
echo " $0 -n # don't display the file"
echo " $0 -c # no color correction (reMarkable2)"
echo " $0 -x # Copy snapshot to clipboard also"
echo " $0 -p # no pixel format correction (reMarkable2 version < 3.6)"
echo " $0 -v # displays version"
echo " $0 --sketch # Construct sketc"
echo " $0 -h # displays help information (this)"
exit 2
;;
Expand Down Expand Up @@ -202,6 +214,21 @@ ssh_cmd "$head_fb0 | $compress" |
-vf "$filters" \
-frames:v 1 "$output_file"

if [ "$construct_sketch" = "true" ]; then
echo "Constructing sketch"
magick "${output_file}" -fill white -draw 'rectangle 0,0 100,100' \
-fill white -draw "rectangle 0,1870 2,1872" \
-transparent white -trim -resize 50% +repage "${output_file}"

output_file=$(realpath "${output_file}")
fi

# Copy to clipboard
if [ "$copy_to_clipboard" = "true" ]; then
echo "Copying to clipboard"
xclip -selection clipboard -t image/png -i "${output_file}"
fi

if [ "$display_output_file" = "true" ]; then
# show the snapshot
feh --fullscreen "$output_file"
Expand Down

0 comments on commit 0dd6089

Please sign in to comment.