As is, this program (script) will not work under MacOS with the built-in bash shell as it does not include mapfile.
Here is a workaround that DOES work... replace each of the three occurrences of mapfile with this equivalent code:
#mapfile -t screensavers < <(peak_into_the_gallery)
screensavers=()
while IFS= read -r line; do
screensavers+=("$line")
done < <(peak_into_the_gallery)
These changes work on my up-to-date MacOS install.