snippets / grab

All snippets tagged grab (1)

  1. printscreen.sh

    Juste un script qui se charge de faire un screenshot, le place dans un répertoire donné, et affiche une miniature de ce qui à été capturé. La capture se fait en utilisant scrot (par défaut) ou import (si scrot n'est pas présent) Testé on Linux and Solaris

      1 #!/usr/bin/env bash
    2 #
    3 #printscreen.sh written by : nali <phobos@goupilfr.org>
    4 # enhanced by : slubman <slubman@ifrance.com>
    5 # this script is free software according to the
    6 # GNU General Public License (see http://www.gnu.org/licenses/gpl.html)
    7 #
    8 #
    9 # This script make a screenshot and save it to a default location
    10 # You can customize some component by editing variables:
    11 # * REP_SAVE
    12 # * IMG_PREF
    13 # * IMG_UNIQ
    14 # * IMG_VIEW
    15 # * IMG_SIZE
    16 #
    17 # The script first try to use the scrot program, if not found it default on import
    18 #
    19 ###########################################################
    20
    21
    22 # Modify the following variables to fetch what you want:
    23 #repertoire des sauvegardes
    24 REP_SAVE=~/Documents/Captures
    25
    26 # Prefixe du nom des images
    27 IMG_PREF=capture
    28
    29 # Estampille (unique) des images
    30 IMG_UNIQ=`date +%Y-%m-%d-%H%M%S`
    31
    32 # View Image (0=no , 1=yes : this feature depend on the display program) ?
    33 IMG_VIEW=1
    34
    35 # Display image resize
    36 IMG_SIZE="840x625"
    37
    38
    39
    40 ###########################################################
    41 # You really don't need to edit anything bellow this line #
    42 ###########################################################
    43
    44 #Delai en sec. avant la capture . Peut etre interessant a mettre par exemple a
    45 #5 ou 10 secondes pour capturer des screen savers.
    46
    47 [ "$1" ] && DELAY=$1
    48
    49 ###########################################################
    50
    51 #repertoire des captures non datees
    52 REP_TEMP=$REP_SAVE/tmp
    53
    54 #creation du repertoire des sauvegardes si il n existe pas
    55 [ ! -d $REP_SAVE ] && mkdir $REP_SAVE
    56
    57 #creation du repertoire des sauvegardes avant "datage", si il n existe pas
    58 [ ! -d $REP_TEMP ] && mkdir $REP_TEMP
    59
    60 ###########################################################
    61
    62 # Verification de l'exitence de import
    63 CAPTURE_CMDS=(scrot import)
    64 for CAPTURE_CMD in ${CAPTURE_CMDS[@]};
    65 do
    66 which $CAPTURE_CMD
    67 if [ $? -eq 0 ]; then
    68 echo "Using $CAPTURE_CMD for the capture !!"
    69 break
    70 fi
    71 done
    72
    73 # Verification de l'exitence de display
    74 if [ IMG_VIEW == "1" -a ! $(which display) ]; then
    75 echo "display program not found, please install ImageMagick (http://www.imagemagick.org)"
    76 exit
    77 fi
    78
    79 #nom de l'image avant datage
    80 NOM_TEMP=$IMG_PREF.png
    81
    82 #nettoyage du temp
    83 cd $REP_TEMP
    84 rm -f $NOM_TEMP
    85
    86 #capture de l'image
    87 [ $DELAY ] && sleep $DELAY
    88 case $CAPTURE_CMD in
    89 scrot)
    90 scrot -m $NOM_TEMP
    91 ;;
    92 import)
    93 import -window root $NOM_TEMP
    94 ;;
    95 *)
    96 echo "Unknown capture command"
    97 exit
    98 ;;
    99 esac
    100
    101
    102 #ajout de la date et heure au nom de la capture
    103 #c'est pas beau mais ca marche :)
    104 SEPARATEUR=-
    105 NOM_DATE=`basename $NOM_TEMP .png`$SEPARATEUR$IMG_UNIQ.png
    106
    107 cp $NOM_TEMP $NOM_DATE
    108
    109 mv $NOM_DATE $REP_SAVE
    110
    111 #affichage en mode reduit
    112 [ $IMG_VIEW == "1" ] && display -resize $IMG_SIZE "$REP_SAVE/$NOM_DATE" &
    113
    114 #nettoyage du temp , pour laisser propre en partant ...
    115 cd $REP_TEMP
    116 rm -f $NOM_TEMP
    Posted by slubman to shell capture grab shell images ... saved by 2 persons ... 1 comments ... 1 year, 2 months
showing 10, 25, 50 items per pages

Pages : 1

Flux RSS friendsnippetLatest snippets


More...