Performance reasons:2) You use the bash builtin mapfile to create arrays in several places. What's the advantage in eg line 169 of doing 'mapfile -t all_walls < <(sort "${wallpaper_list_file}")' instead of 'all_walls=( $(sort "${wallpaper_list_file}"))' ?
From THispage
While mapfile isn't a common or portable shell feature, it's functionality will be familiar to many programmers. Almost all programming languages (aside from shells) with support for compound datatypes like arrays, and which handle open file objects in the traditional way, have some analogous shortcut for easily reading all lines of some input as a standard feature. In Bash, mapfile in itself can't do anything that couldn't already be done using read and a loop, and if portability is even a slight concern, should never be used. However, it does significantly outperform a read loop, and can make for shorter and cleaner code - especially convenient for interactive use.
That is an error on my part.3) On line 174 you use find to go deep into the Images directory tree. If that was my image collection (luckily it's "images" not "Images") it would make a very long list! Better to make a special "wallpaper" directory?
I have added the find option -maxdepth 1 to prevent find going deeper.
That's right. Your suggestion works and does not need to call4) On line 218 ' < <(echo "$gui_selected_walls")' could be '<<<"$gui_selected_walls"' I think, saving a call to echo?
external program echo. So I think it is faster. Thanks.
Right again. And your suggestion is more readable.5) On line 293 'selections_for_active[${#selections_for_active[@]}]="$wall"' could be 'selections_for_active+="$wall"' ?
Changed my script accordingly.
New version available in my github repo.
There is one situation that none of us handles well: when the
filename for a wall oj the server is re-used for another wallpaper,
and we have it installed already, the new version will not get
downloaded unless we manually remove the installed version.
We work with file names, and we should really be working with md5sums
or shasums.
The ideal would be that the server provides a list of file names and
associated shasums for the wallpapers on the server. What do you say
machinebacon?
Enjoy your scripting