Last Updated: February 25, 2016
·
344
· skuldomg

Webcam picture on every git commit

Originally from: http://bneijt.nl/blog/post/webcam-picture-on-every-git-commit/

I changed it up a little so it would fit my needs better. Here's some changes, in case you're wondering:

git:

#!/bin/bash
/usr/bin/git “$@”
ESTATUS=”$?”
if [ “$ESTATUS” = “0” ]; then
    if [ “$1” = “commit” ]; then
        webcamsnapshot “$3”
    fi
fi
exit “${ESTATUS}”

webcamsnapshot:

#!/bin/bash
timestamp=”`date +%Y%m%dT%H:%M:%S`”
activity=$1
if [ -z “$activity” ]; then
    activity=”none”
fi
if [ $# -gt 1 ]; then
    echo “Too many arguments given”
    exit 1
fi
echo “Snapshot activity: ${activity}”
outputPath=”${HOME}/Pictures/webcam/git commits”
mkdir -p “${outputPath}”
cd “${outputPath}” 
/usr/bin/gst-launch-0.10 -e v4l2src num-buffers=1 decimate=10 ! jpegenc \
    ! filesink location=”${timestamp} ${activity} .jpg” \
    > /dev/null 2>&1 < /dev/null &

Pictures are neatly in one folder, sorted by time taken and include their commit message in their filename.