shot §

Captures d'écran avec sélection d'une région, upload, copie dans le presse-papier... Il nécessite le script up.

up/

#!/bin/sh -e

p="screenshot:"
img=/tmp/scrot-$(date +%Y%m%d%H%S).png

case $LANG in
    fr* )
        txtfull="tout l'écran"
        txtfullwait5="tout l'écran après 5 secondes"
        txtselncopy="sélection + presse papier"
        txtsel="sélection"
        txtselwait5="attendre 5s puis sélectionner"
        txtselnup="sélection et upload"
        ;;
    * )
        txtfull="whole screen"
        txtfullwait5="whole screen after 5s"
        txtsel="select"
        txtselwait5="wait 5s and select"
        txtselncopy="select and copy"
        txtselnup="select and upload"
        ;;
esac

action=$(echo "$txtfull
$txtselncopy
$txtfullwait5
$txtsel
$txtselwait5
$txtselnup"| match -p "$p") 

case "$action" in
    "${txtfull}" )
        scrot "${img}"
    ;;
    "${txtfullwait5}" )
        scrot -d5 "${img}"
    ;;
    "${txtsel}" )
        scrot -s "${img}"
    ;;
    "${txtselwait5}" )
        scrot -d5 -s "${img}"
    ;;
    "${txtselncopy}" )
        scrot -s "${img}"
        xclip -selection clipboard -t "image/png" < "$img"
    ;;
    "${txtselnup}" )
        scrot -s "${img}"
        url="$(up "${img}")"
        $BROWSER "$url"
    ;;
esac

exit

#!/bin/sh
# take screenshot with GraphicsMagick
# : $1 : name of the image
S=0
D=0

usage()
{
    echo "usage : scrot [-s|-d] <image-name>"
    echo "    -s: select"
    echo "    -d: delay in sec"
    echo ""
    echo "example : scrot -s -d5 test.png"
    exit
}


while getopts 'sd:' c
do
    case $c in
        s) S=1 ;;
        d) D="${OPTARG}" ;;
    esac
done

shift $((OPTIND - 1))

test -z "${1}" && usage

while [ $D -gt 0 ]; do
    echo "$D"
    sleep 1
    D=$(($D - 1))
done

if [ "$S" -eq 1 ]; then
    gm import "${1}"
else
    gm import -window root "${1}"
fi

echo "${1}"
exit 0