Sergey Kiselev
1 year ago
2 changed files with 77 additions and 1 deletions
@ -0,0 +1,58 @@ |
|||||
|
#!/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 |
||||
|
|
Loading…
Reference in new issue