diff options
author | wxs <wxs@FreeBSD.org> | 2009-04-22 23:13:03 +0800 |
---|---|---|
committer | wxs <wxs@FreeBSD.org> | 2009-04-22 23:13:03 +0800 |
commit | afb7e8a6d9d22e5ebd2b8301067f5ee0752be73e (patch) | |
tree | d4e5074400a5f021fda846effbd7a84e3a66d692 | |
parent | 81ed40ae9856bf597e4ecb862da7443ed8ccc676 (diff) | |
download | freebsd-ports-gnome-afb7e8a6d9d22e5ebd2b8301067f5ee0752be73e.tar.gz freebsd-ports-gnome-afb7e8a6d9d22e5ebd2b8301067f5ee0752be73e.tar.zst freebsd-ports-gnome-afb7e8a6d9d22e5ebd2b8301067f5ee0752be73e.zip |
- Update to 1.3
PR: ports/133669
Submitted by: Alex Kozlov <spam@rm-rf.kiev.ua> (maintainer)
-rw-r--r-- | x11/printscreen/Makefile | 2 | ||||
-rw-r--r-- | x11/printscreen/files/printscreen.in | 87 |
2 files changed, 82 insertions, 7 deletions
diff --git a/x11/printscreen/Makefile b/x11/printscreen/Makefile index a155d9bef8f7..bdf753e437f9 100644 --- a/x11/printscreen/Makefile +++ b/x11/printscreen/Makefile @@ -6,7 +6,7 @@ # PORTNAME= printscreen -PORTVERSION= 1.0 +PORTVERSION= 1.3 CATEGORIES= x11 DISTFILES= diff --git a/x11/printscreen/files/printscreen.in b/x11/printscreen/files/printscreen.in index da9238e43dcd..3a2e7dbaacd7 100644 --- a/x11/printscreen/files/printscreen.in +++ b/x11/printscreen/files/printscreen.in @@ -1,13 +1,88 @@ #!/bin/sh -PATH=/bin:/usr/local/bin +PATH=/bin:/usr/bin:/usr/local/bin +xwdcommon='-nobdrs' +xwdroot='-root' + +INFMT=pnm +OUTFMT=png STOREDIR="${HOME}/.screenshots" SHOTDATE="$(date +%Y.%m.%d-%H.%M.%S)" -SHOTNAME="${STOREDIR}/screenshot-${SHOTDATE}.png" -if [ ! -d "${STOREDIR}" ]; then - mkdir "${STOREDIR}" -fi +parse_options() +{ + local OPT OPTARG OPTIND fmt fmtlist i + + while getopts d:f:bhlqs OPT; do + # escape meta + OPTARG=${OPTARG%%[;\\\$]*} + + case ${OPT} in + b) xwdcommon="${xwdcommon} -frame" ;; + d) delay="${OPTARG}" ;; + f) + OUTFMT="${OPTARG}" + unset INFMT + + for fmt in pnm pbm pgm ppm; do + if [ -x /usr/local/bin/${fmt}to${OUTFMT} ]; then + INFMT=${fmt} + break + fi + done + + [ -z "${INFMT}" ] && usage + ;; + l) + for i in /usr/local/bin/p[nbgp]mto*; do + fmtlist="${fmtlist} $(echo ${i} | \ + sed -Ee's:/usr/local/bin/(pnm|pbm|pgm|ppm)to::')" + done + echo Supported output formats: + echo ${fmtlist} + exit 0 + ;; + q) xwdcommon="${xwdcommon} -silent";; + s) unset xwdroot ;; + h|*) usage ;; + esac + done + + OPTC=$((${OPTIND} - 1)) +} + +usage() +{ + echo "usage: ${0##*/} [-bhlqs] [-d sec] [-f outfmt] [shotname]" + echo ' -b when selecting a window, grab wm border too' + echo ' -d wait sec seconds before taking a shot' + echo ' -f set output format' + echo ' -h display this help and exit' + echo ' -l list output formats' + echo ' -q be silent' + echo ' -s interactively choose a window' + echo + echo "Screenshots stored in ${HOME}/.screenshots" + echo + exit 1 +} + +parse_options ${1+"$@"} +shift ${OPTC} + +if [ -z ${@+1} ]; then + SHOTNAME="${STOREDIR}/screenshot-${SHOTDATE}.${OUTFMT}" +else + SHOTNAME=$1 + shift + + [ -z ${@+1} ] || usage +fi + +[ -d "${STOREDIR}" ] || mkdir "${STOREDIR}" + +[ -n "${delay}" ] && sleep "${delay}" -xwd -root | xwdtopnm 2>/dev/null | pnmtopng 2>/dev/null > "${SHOTNAME}" +xwd ${xwdcommon} ${xwdroot} | xwdtopnm 2>/dev/null | \ + "${INFMT}to${OUTFMT}" 2>/dev/null > "${SHOTNAME}" |