Skip to content

Instantly share code, notes, and snippets.

@circleous
Created March 12, 2017 23:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save circleous/73d80b4b1d9a81822bc4ea043d3317c3 to your computer and use it in GitHub Desktop.
Save circleous/73d80b4b1d9a81822bc4ea043d3317c3 to your computer and use it in GitHub Desktop.
Take screenshot with escrotum and upload it to safe.moe. Taken from https://aur.archlinux.org/packages/pscrotum/
#!/bin/sh
pomf() {
token=""
uppomf="https://safe.moe/api/upload"
if test $# -lt 1 ; then
echo "Usage: `basename $0` FILE [FILE...]"
exit 1
fi
set=
for f ; do
test "$set" || set -- ; set=1
set -- "$@" -F "files[]=@$f"
done
curl -fsSL "$@" "$uppomf" -H "token: $token" | jq -c -r '.files[].url'
}
ARGS=$1
if [ `echo $ARGS | grep h` ]; then
echo "Usage: pscrotum [hsfd]"
echo "-h: Shows this help screen"
echo "-s: Screenshot a selected region"
echo "-f: Screenshot focused window"
echo "-d: Delete image from local storage after uploaded"
echo "ex: pscrotum sd <--Screenshot selection and delete after upload"
exit
fi
fn=`date | sed -e 's/ /-/g' | sed -e 's/:/\./g'`.png
if [ `echo $ARGS | grep s` ]; then
escrotum -s "$fn" && pomf $fn | xclip -sel c; mv -v $fn ~/Pictures/
elif [ `echo $ARGS | grep f` ]; then
escrotum -u "$fn" && pomf "$fn" | xclip -sel c; mv -v $fn ~/Pictures/
else
escrotum "$fn" && pomf "$fn" | xclip -sel c; mv -v $fn ~/Pictures/
fi
if [ `echo $ARGS | grep d` ]; then
rm -vf ~/Pictures/$fn
fi
notify-send -i "Screenshot captured and link copied to clipboard!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment