I posted this on raspberrypi.stackexchange but was directed here. I'm new to Linux / Unix, and I'm trying to get a tether / display script going with gphoto2. gphoto2 --capture-tethered --hook-script=myhookscript.sh \    --filename=/home/media/usbpendrive/image-%Y%m%d-%H%M%S.jpg \    --force-overwriteThis is supposed to download the image to my USB pen drive and then look for new commands in the hookscript.The next stage would be to use qiv or similar image viewer to look for the last capture in the folder, then display it full screen. I would like someone to explain in simple terms how to make this hook script.
gphoto2 hook scripts - a guide?
scripting;images;hook
Gphoto passes $ACTION and $ARGUMENT to the hook script, which you can use.As an example:-#!/bin/bashif [ $ARGUMENT ]; then    if [[ $ARGUMENT =~ .+\.[jpg|JPG] ]]    then    # Then next few lines are optional    # Alternatively pass $ARGUMENT directly to your image viewer eg:-    # /usr/bin/shotwell $ARGUMENT &    DIRNAME=$(dirname $ARGUMENT)    BASENAME=$(basename $ARGUMENT)    NEWFILENAME=$DIRNAME/my_new_folder/$BASENAME    mv $ARGUMENT $NEWFILENAME            /usr/bin/shotwell $NEWFILENAME &    fifiThis opens the file in shotwell, but that's easy to change to your preferred viewer.The second if statement makes sure that shotwell is only used if the downloaded file is a JPG as I sometimes had the camera set to create raw (CR2 on a Canon) which wouldn't open in shotwell.  I suppose it could be expanded to to open those with another viewer.The image will be saved as the argument supplied to --filename - in your case /home/media/usbpendrive/image-20140616-125500.jpg. That will be the value stored in $ARGUMENT and passed to your hook script.You could use dirname and basename to split this path and filename to their relevant parts and then re-use them to create a new path and filename for the image.$dirname /home/media/usbpendrive/image-20140616-125500.jpg/home/media/usbpendrive $basename /home/media/usbpendrive/image-20140616-125500.jpgimage-20140616-125500.jpg$ARGUMENT is only available when gphoto is downloading the image, so a check of $ACTION would be redundant in this case.The file will need to have it's executable bit set, of course.I only stopped using this when I found Entangle but I'm not sure that's available on the Pi. 