himdel / hsetroot

yet another wallpaper application
GNU General Public License v2.0
123 stars 21 forks source link

Background image not set when screen is off #41

Closed LRitzdorf closed 2 years ago

LRitzdorf commented 2 years ago

If hsetroot is called when the display is powered off (i.e. after waiting for ~10 minutes for the display to blank), a rather strange issue regarding background color and image occurs. As an example, we can run sleep 630; hsetroot -solid "#FF0000" -center ~/some-background.png, so that hsetroot is called after the display powers off. In this case, the specified background color applies properly, while the image does not.

I'd be happy to provide further details or logs, if that would help with troubleshooting.

himdel commented 2 years ago

Interesting .. do you have the hsr-outputs command available? Can you try running sleep 630 ; hsr-outputs and compare the results when the screen is on vs off please? I'm suspecting the screen blanking is also removing the output, or changing the position/size and hsetroot is then trying to paint the image in the wrong place .. or something :)

LRitzdorf commented 2 years ago

Well, this is interesting...

$ hsr-outputs
screen_number: 0
    x_org:  0
    y_org:  0
    width:  1920
    height: 1080
$ sleep 630; hsr-outputs
$
himdel commented 2 years ago

Ah, that looks like the output is completely detached when blanked.

Unfortunately that probably means there's not much I can do about it :( .. unless we add some feature to allow you to explicitly define the outputs and sizes using params, hsetroot will not know where to put it.

Would it help if you had a way of noticing the screen came back and running hsetroot then? (I'm currently investigating a way to watch hotplug events to detect a keyboard was plugged in to re-run any xset and xmodmap commands, because keyboard settings also tend to disappear when a keyboard gets plugged in in modern X, so perhaps this could be useful for that as well. Nothing to show yet though :(.)

LRitzdorf commented 2 years ago

That would definitely be acceptable for me. Some kind of "let's just queue this action for when the screen comes back" logic would be great — after all, that's when the results will be visible.

himdel commented 2 years ago

OK, I'll keep you up to date :) (well, I'll try)

But .. actually one more idea .. you're only using one physical screen, right? Because if so, maybe turning the screen detection off would help in your case... can you try running hsetroot with extra -root param?

(Original hsetroot did what -root does by default, but when you have multiple screens, it splits the wallpaper across all of them, instead of painting it on each, that's why I added the screen detection. There's a chance the original behaviour still works for you.)

LRitzdorf commented 2 years ago

Yes, that does indeed work!

Purely out of curiosity, how does -root change the way that hsetroot determines screen size?

himdel commented 2 years ago

Nice! :)

It boils down to https://github.com/himdel/hsetroot/blob/master/hsetroot.c#L266-L306

with -root we're calling DisplayWidth and DisplayHeight from Xlib (https://linux.die.net/man/3/displaywidth) without -root it's XineramaQueryScreens from Xinerama (https://linux.die.net/man/3/xineramaqueryscreens)

(Now I wonder if the default should be -root first and then any found outputs over it.)

LRitzdorf commented 2 years ago

Well, my particular use case was with Pacwall (see the issue linked above), and since that lets you control the "hook" command used to set the wallpaper, I've just added -root there. Defaults are, of course, up to your judgement, but this fixes my original issue.