bbqwall

Submitted scripts and programs
Forum rules
Your own work only.
User avatar
xaos52
The Good Doctor
Posts: 190
Joined: Thu Aug 15, 2013 11:59 am
Location: Eernegem, Belgium

Re: bbqwall

Unread post by xaos52 » Mon Sep 16, 2013 2:42 pm

John,
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}"))' ?
Performance reasons:
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.
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?
That is an error on my part.
I have added the find option -maxdepth 1 to prevent find going deeper.
4) On line 218 ' < <(echo "$gui_selected_walls")' could be '<<<"$gui_selected_walls"' I think, saving a call to echo?
That's right. Your suggestion works and does not need to call
external program echo. So I think it is faster. Thanks.
5) On line 293 'selections_for_active[${#selections_for_active[@]}]="$wall"' could be 'selections_for_active+="$wall"' ?
Right again. And your suggestion is more readable.
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
Connected. Take this REPL, brother, and may it serve you well.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: bbqwall

Unread post by machinebacon » Tue Sep 17, 2013 12:47 pm

^ Can be done, no problem. I'll look into it as soon as I'm back in the country next week. Please PM me about the details of the .list file. Thank you!
..gnutella..

User avatar
johnraff
Sperminator
Posts: 199
Joined: Wed Oct 17, 2012 6:38 pm
Location: Japan
Contact:

Re: bbqwall

Unread post by johnraff » Tue Sep 17, 2013 6:12 pm

xaos, thank you for all that. I knew nothing about 'mapfile' - it does look useful for some situations.
All code is one.

User avatar
johnraff
Sperminator
Posts: 199
Joined: Wed Oct 17, 2012 6:38 pm
Location: Japan
Contact:

Re: bbqwall

Unread post by johnraff » Wed Sep 18, 2013 3:35 am

xaos52 wrote: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.
It wouldn't be too hard for either of the scripts to cope with that, but before we jump in to rewriting, maybe there are a few questions that need to be asked?
  • Under what circumstances would a file be removed from the server and a new one with the same name uploaded?
  • What would be the best action for the script to take then, from the point of view of the user?
  • Is there a possibility of filenames on the server including spaces?
  • Should the wallpapers have descriptive names attached?
  • Is a plain text file the most robust way to send information about the contents of the directory?
  • In general, how will the wallpapers directory be maintained? Manually or automatically?
  • Should there be sugar in the coffee?
[align=center]Image[/align]

Anyway, machinebacon, maybe you could give us some guidelines when you get back? (Meanwhile enjoy your holiday!)
All code is one.

User avatar
xaos52
The Good Doctor
Posts: 190
Joined: Thu Aug 15, 2013 11:59 am
Location: Eernegem, Belgium

Re: bbqwall

Unread post by xaos52 » Wed Sep 18, 2013 7:25 am

@John
I have asked machinebacon to provide a new_wallpaper_list file with sha512 sums of the wallpaper thumbnails.
That will give us sufficient information to find out if things on the server have changed, and what has been changed or removed.
Connected. Take this REPL, brother, and may it serve you well.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: bbqwall

Unread post by machinebacon » Thu Sep 19, 2013 1:43 pm

@john: sorry for my passivity, I was a bit distracted:

Under what circumstances would a file be removed from the server and a new one with the same name uploaded?
- Never. The file names are always "username + number", as we only host own stuff.

What would be the best action for the script to take then, from the point of view of the user?
- The user just gets a list (with thumbnail, if possible), and the list is created manually each time after new wallpapers are added to the server - around once a month.

Is there a possibility of filenames on the server including spaces?
- Usernames don't have spaces on the forums - as an example, your wallpapers would be stared as johnraff01, johnraff02, etc

Should the wallpapers have descriptive names attached?
- This is a nice idea, a descriptions could be added, optionally, in the file list.

Is a plain text file the most robust way to send information about the contents of the directory?
- I just wanted a simple method, and a textfile was the easiest and quickest way to get the stuff done. Are there alternatives? Something like the "packages" file for repos?

In general, how will the wallpapers directory be maintained? Manually or automatically?
- Manually. I can't and won't give random access to John Doe.

Should there be sugar in the coffee?
- "Should there be coffee in the sugar" fits more :)
..gnutella..

Post Reply