Skip to content

Instantly share code, notes, and snippets.

@goto-bus-stop
Created February 1, 2017 09:16
Show Gist options
  • Save goto-bus-stop/3d4ccde5996c58667908e62bdfcbcb23 to your computer and use it in GitHub Desktop.
Save goto-bus-stop/3d4ccde5996c58667908e62bdfcbcb23 to your computer and use it in GitHub Desktop.
Screenshot + upload to ipfs. Usage: `screenshot-ipfs`
#!/bin/sh
OUTPUT_FOLDER=~/Pictures/scrs
TMP_FILE=/tmp/screenshot.png
# Get size by letting user draw a rectangle with `slop`
size=$(slop)
[ $? = 0 ] || exit 1; # Exit if drawing was cancelled.
eval $size
# Take a screenshot of the entire screen
scrot -d 0.1 "$TMP_FILE"
# Crop the screenshot to the selected area and move it to the screenshots dir
output="${OUTPUT_FOLDER}/scr_$(date +%Y-%m-%d_%H-%M-%S).png"
convert "$TMP_FILE" -crop "$W"x"$H"+"$X"+"$Y" "$output"
# Return the output filename
echo -n "$output"
#!/bin/sh
screen="$(make-screenshot)"
[ $? = 0 ] || { notify-send "Aborted" ; exit 1; };
objectid="$(ipfs add "$screen" | cut -d' ' -f2)"
echo "https://gateway.ipfs.io/ipfs/$objectid" \
| xclip -sel c \
&& notify-send "Uploaded" \
|| notify-send "Aborted"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment