#!/bin/sh # this script takes a screenshot using xwd, gimp, and pngcrush. # it is mostly a proof-of-concept for command-line gimp. # #TODO : add noxmessage option #TODO : don't check if things exist if they aren't being run if [ "${1}" = "-u" ] ; then NOPNGCRUSH="TRUE" export NOPNGCRUSH fi if [ "${1}" = "-h" ] ; then echo This script takes a screenshot as a png in the echo current working directory in the form of echo "HH-MM.SS_scrn.png". This format allows for a echo good chance of no conflicting files. It requires: echo X11, GIMP \& pngcrush to be installed. It also echo requires /tmp and the current working directory echo to be writeable. It, however does not require echo \"ImageMagick\" as the conversion is done in GIMP echo \(batch-mode\). echo echo "Title: gimp_scrn.sh" echo "Author: Greg Schenzel" echo "Liscence: GNU General Public Liscence v2" echo "Usage: $0 -u/-h" echo " -u :: save png uncompressed (to bypass pngcrush" echo " if not installed). you may also set" echo " NOPNGCRUSH to \"TRUE\" in your environment." echo " -h :: print this message." exit fi if [ ! -w /tmp ] ; then echo "FATAL: /tmp is not writeable." exit fi if [ ! -w ${PWD} ] ; then echo "FATAL: ${PWD} is not writeable." exit fi if ! whereis gimp ; then echo "GIMP not found." exit fi if ! whereis xwd ; then echo "XWD not found. (Is X11 installed?)." exit fi if ! whereis xmessage ; then echo "XMESSAGE not found. (Is X11 installed?)." exit fi if ! whereis pngcrush ; then echo "pngcrush not found." exit fi FILE=`whoami`_scrn export FILE RF1=/tmp/${FILE}.xwd RF2=/tmp/${FILE}.png RF3=$PWD/`date +%H-%M.%S_scrn.png` export RF1 RF2 RF3 xwd -root > /tmp/${FILE}.xwd gimp --no-interface --no-data --batch "(file-xwd-load 1 \"${RF1}\" \"${RF1}\")" "(file-png-save 1 0 (car (gimp-image-active-drawable 0)) \"${RF2}\" \"${RF2}\" 0 0 1 0 0 0 0)" "(gimp-quit 0)" if [ "TRUE" = "${NOPNGCRUSH}" ] then cp ${RF2} ${RF3} else pngcrush -q ${RF2} ${RF3} fi rm ${RF1} ${RF2} xmessage "The screenshot has completed."