Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # tethered.sh - Tethered shooting script for Nikon DSLRs and gphoto2
- # based upon the test-hook.sh script by Hans Ulrich Niedermann.
- # Written by Juan Julio Peña AKA Apollux
- #
- # This library is free software; you can redistribute it and/or
- # modify it under the terms of the GNU Lesser General Public
- # License as published by the Free Software Foundation; either
- # version 2 of the License, or (at your option) any later version.
- #
- # This library is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- # Lesser General Public License for more details.
- #
- # You should have received a copy of the GNU Lesser General Public
- # License along with this library; if not, write to the
- # along with this library; if not, write to the Free Software
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- # Finds out the script's own file name.
- SCRIPT_NAME=`basename $0`
- # The name of the file been downloaded from the camera, as passed by gphoto2
- FILE_NAME=$ARGUMENT
- case "$ACTION" in
- init)
- # Nothing happends here, gphoto2 has initiated operations
- # exit 1 # decomment this line to cause a non-null exit, thus making the gphoto2 call fail immediately
- ;;
- start)
- # gphoto2 started processing it's command line. In other words, nothing happends here.
- ;;
- download)
- #The picture(s) has been downloaded from the camera, time to take action.
- echo "$FILE_NAME was succesfuly downloaded!"
- # This uses a bash parameter-expansion trick to get the last 3 characters of the FILE_NAME variable.
- LENGHT_OF_NAME=${#FILE_NAME}
- FILE_EXTENSION=${FILE_NAME:(($LENGH_OF_NAME-3)):3}
- # Let's see what type of file was downloaded from the camera.
- case "$FILE_EXTENSION" in
- (NEF)
- # The file is a RAW image, so nothing is done. Do you really want to proccess a RAW file in real time?
- echo "RAW (.NEF) file detected, skipped"
- ;;
- (JPG)
- # The file is a JPEG image, so let's display it on all it's glory.
- # First, kills any previously open viewer window, to save on RAM memory.
- pkill gwenview
- # Now, use the gwenview viewer to show the file on full screen mode
- gwenview -f $FILE_NAME &
- ;;
- (*)
- # The downloaded file isn't a NEF nor a JPG, what is your camera producing?
- echo "An unknown file tipe was downloaded from the camera, better check your settings!"
- ;;
- esac
- ;;
- stop)
- date
- ;;
- *)
- echo "Unknown action: $ACTION"
- ;;
- esac
- # Operation has been successful.
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement