FallingSnow / lightdm-webkit2-material2

A material design LightDM Webkit2 greeter theme
Do What The F*ck You Want To Public License
112 stars 16 forks source link

Wallpaper sometimes show default one #14

Open koxu1996 opened 6 years ago

koxu1996 commented 6 years ago

Hello. I have been using your theme from some time and there is one annoying issue: sometimes instead of random wallpaper, default one (no-mans-sky.jpg) appears. Do you know, what might cause this problem?

FallingSnow commented 6 years ago

That would suggest that the random wallpaper is not accessable and the fallback takes over. Try putting the greeter into debug mode and see what the css rule for the background is. See if that path is accessible.

Actually now that I think about it check to see if all the wallpapers have the same permissions, perhaps the greeter isn't allowed to access some of them and when those are randomly selected, the greeter fallback to the default.

koxu1996 commented 6 years ago

That link is confusing, because now lightdm-webkit2-greeter is changed to web-greeter. But I managed to enable debug mode in /etc/lightdm/lightdm-webkit2-greeter.conf and after running lightdm-webkit2-greeter I get debug messages:

file:///usr/share/lightdm-webkit/themes/material2/bundle.js:62:4217: CONSOLE DEBUG Loading Theme
file:///usr/share/lightdm-webkit/themes/material2/bundle.js:72:4198: CONSOLE DEBUG Main loaded. [object Object]
file:///usr/share/lightdm-webkit/themes/material2/bundle.js:71:14262: CONSOLE DEBUG App loaded. [object Object]
file:///usr/share/lightdm-webkit/themes/material2/bundle.js:71:18485: CONSOLE DEBUG Background loaded. [object Object]
file:///usr/share/lightdm-webkit/themes/material2/bundle.js:71:19726: CONSOLE DEBUG Updated background. random-image
file:///usr/share/lightdm-webkit/themes/material2/bundle.js:71:19953: CONSOLE DEBUG Clock Locale set to: en
file:///usr/share/lightdm-webkit/themes/material2/bundle.js:72:19719: CONSOLE DEBUG RandomImage loaded. [object Object]
file:///usr/share/lightdm-webkit/themes/material2/bundle.js:47:925: CONSOLE DEBUG Image loaded. [object Object]
file:///usr/share/lightdm-webkit/themes/material2/bundle.js:71:29975: CONSOLE DEBUG Login loaded. [object Object]
file:///usr/share/lightdm-webkit/themes/material2/bundle.js:71:24680: CONSOLE DEBUG Footer loaded. [object Object]
file:///usr/share/lightdm-webkit/themes/material2/bundle.js:71:22609: CONSOLE DEBUG Console loaded. [object Object]

There is no error, but wrong wallpaper is loaded. How I can browser these logs, to check what is exactly under [object Object]?

Edit: I see there is option to inspect when clicking right mouse button. Give me some time and I will figure out what is wrong.

koxu1996 commented 6 years ago

I figured out the problem. My folder with wallpapers look like this:

.                    
├── Arch.jpeg                      
└── gnome            
    ├── adwaita-day.jpg     
    ├── adwaita-lock.jpg
    ├── adwaita-morning.jpg
...

These are console outputs:

As you can see, in later case gnome directory is selected as wallpaper and this is fallbacking to default wallpaper.

Solution would be to look only for files which are not directories, but I can't see any greeter api function to achieve this.

FallingSnow commented 6 years ago

tl;dr Change your directory structure so that the issue doesn't occur.

Well at least you know what the issue is. It is actually possible to search the directories as well for images. However this may not be what the user wants (recursively searching directories)... and I don't want to write a toggle just for that specific scenario.

Instead it would be beneficial to just filter out the directories and only display the images at the selected directory.

koxu1996 commented 6 years ago

Sample of filtering files by extension:

var imagesExtensions = ["jpg", "jpeg", "png"];
function isImage(path) {
   filename = path.substring(path.lastIndexOf("/") + 1);
   if ((dotPosition = filename.lastIndexOf("."))  > -1) {
      extension = filename.substring(dotPosition + 1); console.log(extension);
      if (imagesExtensions.indexOf(extension) > -1) {
          return true;
      }
   }
   return false;
}
greeterutil.dirlist('/usr/share/backgrounds').filter(isImage);

@FallingSnow what do you think about something like this?

koxu1996 commented 6 years ago

@FallingSnow Should I create Pull Request?

FallingSnow commented 6 years ago

Sure. I might have a few more comments when you submit the pull request, not sure yet lol.