Created
August 29, 2017 01:37
-
-
Save taylor/b12b7bc1f1e2442cb2670068791b832b 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 | |
# uses scrot for capture | |
# and imgur for posting | |
SCROT=scrot | |
#SCROT=escrotum | |
post=0 | |
scrotargs="" | |
selectopt="-s" | |
filename='%Y-%m-%d-%H%M_$wx$h.png' | |
execcmd="imgur" | |
postex="" | |
function usage() { | |
me=$(basename $0) | |
echo "$me [options] [scrot options]" | |
echo "Options for $me:" | |
echo " -i|-imgur|-p|-u - Upload to imgur.com" | |
echo " -c|-clipboard - Copy screenshot to clipboard" | |
echo " -s|-select - Select part of the screen" | |
echo " -a|-all - Capture all of the screen (default)" | |
echo " -t|-w|-wait - Wait 5 seconds before capture" | |
echo " -h|-help|-usage - This help" | |
} | |
wait=0 | |
while [ true ] ; do | |
case "$1" in | |
-h|-help|--help|-usage) | |
usage | |
exit | |
;; | |
-c|-clipboard) | |
USE_CLIPBOARD=1 | |
if [ "$SCROT" = "escrotum" ] ; then | |
postex="" | |
scrotargs="$scrotargs -C" | |
else | |
postex="-e" | |
execcmd="$HOME/bin/imgclip.py" | |
fi | |
shift | |
;; | |
-i|-imgur|-p|-post|-u) | |
postex="-e" | |
shift | |
;; | |
-s|-select) | |
selectopt="-s" | |
shift | |
;; | |
-a|-all) | |
selectopt="" | |
shift | |
;; | |
-t|-w) | |
wait=5 | |
shift | |
;; | |
*) | |
scrotargs="$scrotargs $1" | |
shift | |
;; | |
esac | |
[[ -z "$1" ]] && break | |
done | |
scrotargs="$scrotargs $selectopt" | |
if [ ! "$wait" = 0 ] ; then | |
sleep $wait | |
fi | |
sleep 0.50 | |
if [ "$USE_CLIPBOARD" = 1 ] ; then | |
exec $SCROT "$filename" $scrotargs $postex "$execcmd \$f" 2> /dev/null | |
# exec $SCROT "$filename" $scrotargs | |
# copyq write image/png - < "$filename" | |
# copyq select 0 | |
# rm -v "$filename" | |
elif [ -n "$postex" ] ; then | |
exec $SCROT "$filename" $scrotargs $postex "$execcmd \$f" | |
else | |
exec $SCROT "$filename" $scrotargs | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment