Created
September 8, 2017 01:15
-
-
Save JoeDupuis/199f7c87e1fc8e9c293426b1d82e14cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -u | |
set -x | |
# Needs: | |
# - slop | |
# - ffmpeg | |
################################################## | |
# Configuration | |
################################################## | |
# The name of the file. Extension will decide the format scrot will output. | |
FILENAME=$(date +%Y%m%d%H%M%S)".mp4" | |
BUCKET_URI="s3://joe-dupuis-temp-uploads/screenshots" | |
DATE_SUBFOLDER="$(date +%Y)/$(date +%m)" | |
# Local folder to keep the copies | |
LOCAL_SCREENSHOTS_FOLDER=~/Dropbox/Public/screenclip/$DATE_SUBFOLDER | |
UPLOAD_URI="${BUCKET_URI}/${DATE_SUBFOLDER}/${FILENAME}" | |
# Stop here | |
################################################################################ | |
################################################################################ | |
# Functions | |
################################################################################ | |
# Print and run | |
_() { | |
printf " > %s\n" "$*" | |
"$@" | |
} | |
# Wrapper with pre-configured stuff | |
_slop() { | |
slop -b 10 -c 0.5,0.5,0.8,0.5 "$@" | |
} | |
# Where the screenshot will go. | |
# Making the folder | |
mkdir -p "$LOCAL_SCREENSHOTS_FOLDER" | |
# Getting to it | |
cd "$LOCAL_SCREENSHOTS_FOLDER" | |
# Take the screenshot! | |
# Pass additional parameters to ffmpeg | |
echo bob | |
read -r X Y W H G ID < <(slop -f '%x %y %w %h %g %i') | |
echo $X $Y | |
echo lol | |
# Makes them divisible by two. | |
W=$(( W / 2 * 2 )) | |
H=$(( H / 2 * 2 )) | |
ffmpeg \ | |
-f x11grab \ | |
-s "$W"x"$H" -i ":0.0+$X,$Y" \ | |
-pix_fmt yuv420p \ | |
"$FILENAME" || : | |
#-f alsa -i pulse \ | |
#-strict -2 \ | |
# Let everything settle down a bit... | |
sleep 0.3 | |
[ -e "$FILENAME" ] | |
################################################################################ | |
_ aws s3 cp "${FILENAME}" "${UPLOAD_URI}" | |
url="$(aws s3 presign $UPLOAD_URI)" | |
# Copying the screenshot's url. | |
echo -n "$url" | xclip -sel clip | |
echo "$url" | |
# Showing a friendly pop-up! | |
notify-send 'Screenclip' \ | |
"Screenclip taken.\n${url}\n\nCopied to the clipboard." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment