Skip to content

Instantly share code, notes, and snippets.

@onjin
Last active December 22, 2015 11:29
Show Gist options
  • Save onjin/6466361 to your computer and use it in GitHub Desktop.
Save onjin/6466361 to your computer and use it in GitHub Desktop.
Command to get region screenshot and publish it on Dropbox
#!/bin/bash
#
# Gets screenshot using imagemagick import command
# puts it in Dropbox folder and returns dropbox url
# to screenshot
# Usage: dropshot [suffix]
# suffis - is optional, default 'dropshot'
# screenshots target directory
DEST_DIR=${HOME}/Dropbox/Public/dropshot
# screenshot type
# TODO: get it from args
EXT='jpg'
if [ -z $1 ]; then
SUFFIX='dropshot'
else
SUFFIX=$1
fi
mkdir -p ${DEST_DIR}
SHOT_FILE="${DEST_DIR}/"`date +%Y%m%d%H%M%S`"_${SUFFIX}.${EXT}"
# imagemagick 'import' command
import ${SHOT_FILE}
# return dropbox public url to screenshot
if ! which xclip > /dev/null; then
echo `dropbox puburl ${SHOT_FILE}`
else
dropbox puburl ${SHOT_FILE} | xclip -sel clip
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment