Update documentation - increase Doxygen usage
[geeqie.git] / plugins / tethered-photography / geeqie-tethered-photography
1 #!/bin/bash
2
3 ## @file
4 ## @brief Simple tethered photography helper
5 ##
6 ## Requires gphoto2
7 ##
8 ## If a file already exists with the same name, it is not overwritten, but the
9 ## download will not take place.
10 ## Auto-rename can be achieved with the --filename option of gphoto2.  
11 ## In file $HOME/.config/gphoto2/settings, set the option:  
12 ## gphoto2=filename=<see the manual>
13 ##
14
15 n=$(ps -e | grep "geeqie-tethered" | wc -l)
16 if [ "$n" -ge 3 ]
17 then
18         exit 0
19 fi
20
21 if ! [ -x "$(command -v gphoto2)" ]
22 then
23         zenity --title="Geeqie tethered photography" --info --width=200 --text="gphoto2 is not installed" 2>/dev/null
24         exit 0
25 fi
26
27 if [ $(gphoto2 --auto-detect | wc -l) -le 2 ]
28 then
29         zenity --error --title="Geeqie tethered photography" --text="No camera detected" --window-icon=/usr/local/share/pixmaps/geeqie.png --width=250 2>/dev/null
30         exit 0
31 fi
32
33 notify-send --expire-time=2000 "$(gphoto2 --auto-detect | sed -n '3p')" --icon=geeqie
34
35 script_dir=$(dirname "$0")
36
37 tmpfile=$(mktemp --tmpdir geeqie_tethered_photography_XXXXXX)
38
39 yes n | gphoto2 --hook-script "$script_dir/"geeqie-tethered-photography-hook-script --capture-tethered >$tmpfile &
40
41 gphoto2_pid=$!
42
43 zenity --question --title="Geeqie tethered photography" --ok-label="Stop" --cancel-label="Show log data" --text="Tethered photography is running.\n\n\nDownloading to folder:\n""$PWD\n\n\nExisting files will not be overwritten,\nbut the download will not take place.\n\n(Use gphoto2 --filename default option\nfor auto-rename on download)" --width=300 --window-icon=/usr/local/share/pixmaps/geeqie.png 2>/dev/null
44
45 if [ $? == 1 ]
46 then
47         zenity --text-info --title="Geeqie tethered photography" --window-icon=/usr/local/share/pixmaps/geeqie.png --ok-label="Stop" --cancel-label="Abort" <$tmpfile 2>/dev/null
48 fi
49
50 kill $gphoto2_pid
51 rm $tmpfile