Advertisement
Guest User

Untitled

a guest
Oct 20th, 2011
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # tethered.sh - Tethered shooting script for Nikon DSLRs and gphoto2
  4. # based upon the test-hook.sh script by Hans Ulrich Niedermann.
  5. # Written by Juan Julio Peña AKA Apollux
  6. #
  7. # This library is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU Lesser General Public
  9. # License as published by the Free Software Foundation; either
  10. # version 2 of the License, or (at your option) any later version.
  11. #
  12. # This library is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. # Lesser General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Lesser General Public
  18. # License along with this library; if not, write to the
  19. # along with this library; if not, write to the Free Software
  20. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21.  
  22. # Finds out the script's own file name.
  23. SCRIPT_NAME=`basename $0`
  24. # The name of the file been downloaded from the camera, as passed by gphoto2
  25. FILE_NAME=$ARGUMENT
  26.  
  27. case "$ACTION" in
  28. init)
  29. # Nothing happends here, gphoto2 has initiated operations
  30. # exit 1 # decomment this line to cause a non-null exit, thus making the gphoto2 call fail immediately
  31. ;;
  32. start)
  33. # gphoto2 started processing it's command line. In other words, nothing happends here.
  34. ;;
  35. download)
  36. #The picture(s) has been downloaded from the camera, time to take action.
  37. echo "$FILE_NAME was succesfuly downloaded!"
  38.  
  39.  
  40. # This uses a bash parameter-expansion trick to get the last 3 characters of the FILE_NAME variable.
  41. LENGHT_OF_NAME=${#FILE_NAME}
  42. FILE_EXTENSION=${FILE_NAME:(($LENGH_OF_NAME-3)):3}
  43.  
  44. # Let's see what type of file was downloaded from the camera.
  45. case "$FILE_EXTENSION" in
  46. (NEF)
  47. # The file is a RAW image, so nothing is done. Do you really want to proccess a RAW file in real time?
  48. echo "RAW (.NEF) file detected, skipped"
  49. ;;
  50. (JPG)
  51. # The file is a JPEG image, so let's display it on all it's glory.
  52. # First, kills any previously open viewer window, to save on RAM memory.
  53. pkill gwenview
  54. # Now, use the gwenview viewer to show the file on full screen mode
  55. gwenview -f $FILE_NAME &
  56. ;;
  57. (*)
  58. # The downloaded file isn't a NEF nor a JPG, what is your camera producing?
  59. echo "An unknown file tipe was downloaded from the camera, better check your settings!"
  60. ;;
  61. esac
  62.  
  63. ;;
  64. stop)
  65. date
  66. ;;
  67. *)
  68. echo "Unknown action: $ACTION"
  69. ;;
  70. esac
  71.  
  72. # Operation has been successful.
  73. exit 0
  74.  
  75.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement