Funny and useful scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

58 lines
1.0 KiB

#!/bin/sh
#
_usage() {
cat <<EOF
Usage:
scrn-sht -o <clip|file>
-h - show this help
-o clip - grab screenshot to clipboard
-o file - grab screenshot and save it to the file
EOF
exit ${1}
}
if [ $# -lt 1 ]; then _usage 2; fi
DATE=$( date +%Y%m%d_%H%M%S )
DIR="${HOME}/media/screenshots"
FILE="${DIR}/$( hostname | cut -d. -f1 )_${DATE}.png"
SHOT=$( which import )
XCLIP=$( which xclip )
[ -z ${SHOT} ] && {
echo "ER: no screenshot app in \$PATH"
echo "IN: provide ${lightgreen}import${nc} from ImageMagick(1) into your \$PATH"
exit 1
}
[ -z ${XCLIP} ] && {
echo "ER: no xclip app in \$PATH"
echo "IN: provide ${lightgreen}xclip${nc} into your \$PATH"
exit 1
}
mkdir -p ${DIR} || {
echo "ER: cannot create ${DIR} dir"
exit 1
}
while getopts ho: OPT; do
case ${OPT} in
o)
case ${OPTARG} in
clip)
${SHOT} -frame -silent png:- | \
${XCLIP} -selection clipboard -target image/png
;;
file) ${SHOT} -frame -silent ${FILE} ;;
esac
;;
h) _usage 0 ;;
*) _usage 2 ;;
esac
done