4 ## @brief Select and display a random image from a list of all images
5 ## in Collections and the currently displayed folder
8 # get list of images in all collections
9 collection_list=$(geeqie --remote --get-collection-list)
11 while IFS= read -r line
13 collection=$(geeqie --remote --get-collection:"$line")
14 list="$list""$collection"$'\n'
15 done <<< "$collection_list"
18 # get list of images in current folder
19 file_list=$(geeqie --remote --get-filelist:)
21 while IFS= read -r line
23 class_whitespace="${line##*Class:}"
24 class="${class_whitespace#"${class_whitespace%%[![:space:]]*}"}"
26 if [ "$class" == "Image" ]
28 list="$list""${line%%Class*}"$'\n'
31 if [ "$class" == "RAW Image" ]
33 list="$list""${line%%Class*}"$'\n'
39 files_no_blanks=$(echo "$list" | sed -e 's/^[[:blank:]]*$//')
40 # remove leading trailing whitespace
41 files_no_spaces=$(echo "$files_no_blanks" | sed 's/^[ \t]*//;s/[ \t]*$//')
43 # remove duplicate lines and select random line
44 display_image="$(echo "$files_no_spaces" | sort --uniq | shuf -n 1)"
46 # get image currently displayed
47 current_image_collection=$(geeqie --remote --tell)
48 # remove collection name, if it is there
49 current_image_spaces="${current_image_collection%%Collection:*}"
50 # remove leading trailing whitespace
51 curent_image=$(echo "$current_image_spaces" | sed 's/^[ \t]*//;s/[ \t]*$//')
53 # if the selected random image is currently displayed, try again
54 if [ "$current_image" == "$display_image" ]
56 display_image="$(echo "$files_no_spaces" | sort --uniq | shuf -n 1)"
59 geeqie --remote file:"$display_image"