Screenshot script

Forum: Programming and Scripting
Topic: Screenshot script
started by: jpeters

Posted by jpeters on Dec. 03 2007,04:33
Works with imagemagick.uci.  Takes arguments for choosing a window <win>, area <area>, or screen <scr>. Creates and stores to $HOME/screenshots/


# Just run it with the argument "win" (for a screenshot of a certain window),
# "scr" (for a screenshot of the entire screen) or "area" (for a screenshot of
# the selected area).

# load imagemagick if not loaded
[ -d /opt/imagemagick ] || mydsl-load /mnt/hda3/imagemagick.uci

DIR="${HOME}/screenshots" DATE="$(date +%Y%m%d@%H%M%S)"
NAME="${DIR}/screenshot-${DATE}.png" LOG="${DIR}/screenshots.log"

# Check if the dir to store the screenshots exists, else create it:
if [ ! -d "${DIR}" ]; then mkdir "${DIR}"; fi

# Screenshot a selected window
if [ "$1" = "win" ]; then $IMGK/import "${NAME}"; fi

# Screenshot the entire screen
if [ "$1" = "scr" ]; then $IMGK/import -window root "${NAME}"; fi

# Screenshot a selected area
if [ "$1" = "area" ]; then $IMGK/import "${NAME}"; fi

if [[ $# = 0 ]]; then
 # Display a warning if no area defined
 echo "No screenshot area has been specified. Screenshot not taken." echo
"${DATE}: No screenshot area has been defined. Screenshot not taken." >>
"${LOG}" else
 # Save the screenshot in the directory and edit the log
 echo "${NAME}" >> "${LOG}" fi

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.