-SUBDIRS = rotate symlink ufraw import geocode-parameters export-jpeg tethered-photography camera-import image-crop
+SUBDIRS = rotate symlink ufraw import geocode-parameters export-jpeg tethered-photography camera-import image-crop random-image
qq_desktoptemplatedir = $(appdir)
qq_desktoptemplate_in_files = template.desktop.in
qq_desktoptemplate_DATA = $(qq_desktoptemplate_in_files:.desktop.in=.desktop)
--- /dev/null
+dist_gq_bin_SCRIPTS = geeqie-random-image
+
+gq_desktopdir = $(appdir)/applications
+gq_desktop_in_files = random-image.desktop.in
+gq_desktop_DATA = $(gq_desktop_in_files:.desktop.in=.desktop)
+@INTLTOOL_DESKTOP_RULE@
+
+EXTRA_DIST = $(gq_desktop_in_files)
+CLEANFILES = $(gq_desktop_DATA)
--- /dev/null
+#!/bin/bash
+
+# Select and display a random image from a list of all images
+# in Collections and the currently displayed folder
+
+# get list of images in all collections
+collection_list=$(geeqie --remote --get-collection-list)
+OLDIFS=$IFS
+while IFS= read -r line
+do
+ collection=$(geeqie --remote --get-collection:"$line")
+ list="$list""$collection"$'\n'
+done <<< "$collection_list"
+IFS=$OLDIFS
+
+# get list of images in current folder
+file_list=$(geeqie --remote --get-filelist:)
+OLDIFS=$IFS
+while IFS= read -r line
+do
+ class_whitespace="${line##*Class:}"
+ class="${class_whitespace#"${class_whitespace%%[![:space:]]*}"}"
+
+ if [ "$class" == "Image" ]
+ then
+ list="$list""${line%%Class*}"$'\n'
+ fi
+
+ if [ "$class" == "RAW Image" ]
+ then
+ list="$list""${line%%Class*}"$'\n'
+ fi
+done <<< "$file_list"
+IFS=$OLDIFS
+
+# remove blank lines
+files_no_blanks=$(echo "$list" | sed -e 's/^[[:blank:]]*$//')
+# remove leading trailing whitespace
+files_no_spaces=$(echo "$files_no_blanks" | sed 's/^[ \t]*//;s/[ \t]*$//')
+
+# remove duplicate lines and select random line
+display_image="$(echo "$files_no_spaces" | sort --uniq | shuf -n 1)"
+
+# get image currently displayed
+current_image_collection=$(geeqie --remote --tell)
+# remove collection name, if it is there
+current_image_spaces="${current_image_collection%%Collection:*}"
+# remove leading trailing whitespace
+curent_image=$(echo "$current_image_spaces" | sed 's/^[ \t]*//;s/[ \t]*$//')
+
+# if the selected random image is currently displayed, try again
+if [ "$current_image" == "$display_image" ]
+then
+ display_image="$(echo "$files_no_spaces" | sort --uniq | shuf -n 1)"
+fi
+
+geeqie --remote file:"$display_image"
plugins/tethered-photography/tethered-photography.desktop.in
plugins/camera-import/camera-import.desktop.in
plugins/image-crop/image-crop.desktop.in
+plugins/random_image/random_image.desktop.in
plugins/rotate/rotate.desktop.in
plugins/symlink/symlink.desktop.in
plugins/template.desktop.in