rishuinfinity / WallpaperSwitcher

Gnome Extension to switch wallpaper after a given interval
GNU General Public License v3.0
33 stars 6 forks source link

Only 30% of images in folder are displayed #18

Open api2001 opened 1 year ago

api2001 commented 1 year ago

Dear developer, thanks a lot for your great and simple contribution to have a nice slide show of my private wallpapers. I have around 40 images in my folder. However although running the random mode I had the impression that images were somehow mostly the same. After some analyses I found out: Yes, only around 13 images out of 40 are randomly rotated, but the rest is never shown. Do you have an idea why this could be? Cheers, APi

rishuinfinity commented 1 year ago

I don't think this should be the case, this is the code responsible for random wallpaper setting

let idx = Math.floor(Math.random() * wallpaperList.length);
wallpaperSetter(wallpaperList[idx]);   

You can test out if the randomness is true by using a smaller dataset, say 3-5 images.

I think the reason you are experiencing that they are not random because:

simmoor commented 1 year ago

Hi there,

thanks for the quick reply. As you said the problem could not be the random generator itself I took another look at my images and found:

20 of them had ".JPG" as extension and not ".jpg". But only .jpg images are displayed. Now that I renamed all .JPG to .jpg all images are perfectly displayed!

As the .JPG images were all photos copied from a digital camera / smartphone named IMG_XXXX.JPG and renaming these every time is kind of stupid work, maybe you could consider to take over images with upper case extensions as well? As I see in your code this might be done in lib.js:

159          let ext = child.get_name().split(".").pop();
160          if(["png","jpg","jpeg"].includes(ext))

Best regards, APi

rishuinfinity commented 1 year ago

Thanks for pointing this out, I'll update the code as soon as possible.