23ce The FreeBSD Forums - View Single Post - Useful scripts
Thread: Useful scripts
View Single Post
  #24  
Old January 14th, 2009, 18:06
vermaden's Avatar
vermaden vermaden is offline
Giant Locked
 
Join Date: Nov 2008
Location: pl_PL.lodz
Posts: 2,192
Thanks: 59
Thanked 633 Times in 349 Posts
Default Universal screenshot

A script that will make a screenshot @ FreeBSD/OpenSolaris/Linux OS:

Code:
#! /bin/sh

DATE=$( date +%Y.%m.%d_%H:%M:%S )
APPS="scrot imlib2_grab import"
DIR=~/gfx/screenshots
FILE=${DIR}/vermaden_${DATE}.png

[ ${#} -ne 0 ] && FILE="${@}"

for I in ${APPS}
do
  which ${I} 1> /dev/null 2> /dev/null && {
    SHOT=${I}
    break
  }
done

[ -z $SHOT ] && {
  echo "ER: no screenshot application in \$PATH"
  echo "IN: provide one of [ scrot | import | imlib2_grab ] into your \$PATH"
  exit 1
}

mkdir -p ${DIR} || {
  echo "ER: cannot create ${DIR} dir"
  exit 1
}

case ${SHOT} in
  (import) import -display :0.0 -window root ${FILE} ;;
  (*)      ${SHOT} ${FILE} ;;
esac
__________________
Religions, worst damnation of mankind.
"FreeBSD has always been the operating system that GNU/Linux should have been." Frank Pohlmann, IBM
http://vermaden.blogspot.com
Reply With Quote
The Following 2 Users Say Thank You to vermaden For This Useful Post:
chalbersma (January 18th, 2009), Maredelamer (August 13th, 2011)
 
0