Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: High performance X11 animated wallpapers (github.com/glouw)
188 points by glouwbug on Aug 2, 2020 | hide | past | favorite | 65 comments


So the animated wallpaper scene on linux is pretty bizarre. There are some popular methods out there like calling `feh --fill-bg` continuously in a bash loop but it sends your CPU usage to an astronomical 40% which drains the laptop battery pretty quickly. I couldn't find a reasonable animated desktop wallpaper setter, so I wrote a little utility in 150 lines or so in C that I call from .xinitrc to randomly pick a fairly unobtrusive desktop scene when I startx.

Quick youtube showcase: https://www.youtube.com/watch?v=6ZTiA885bWM


for animated stuff I had good results with setting mpv as background. though yours looks like it uses even less CPU, super nice :) will work wonders with https://1041uuu.tumblr.com stuff !

... or at least it would, if I was seeing my desktop background once in a while


True that, MPV is solid. Paperview gives me ~3% cpu usage and ~9% GPU usage on an old x230, while MPV gives me 40% cpu usage for a similar mp4. MPV works great on desktops with mp4s, while paperview is great for laptops and battery life if 15 frame gifs are being rendered (pixel art, of course!)


> ... or at least it would, if I was seeing my desktop background once in a while

One of the very few reasons I miss stacking window managers:)


>setting mpv as background

how does one do this? Just replace the Feh call with mpv?


    mpv foo.mp4 --wid=0


Really it should be something built in to the DE. You need it to stop rendering when the background is covered.


You can accomplish this with straight X11, no need for the DE to be aware of it.


I don't think that's so trivial in a composited world. IIRC once upon a time you could easily get a viewable state from the X server for windows, but with compositing xorg made it basically always true.


In wayland it's very simple. You would use surface frame callbacks, which aren't supposed to trigger when the window is fully obscured, minimized, or off-screen on another desktop. This mechanism never seems to have made it back into composited X.


>In wayland it's very simple

This seems to be the trend


GNOME has backgrounds which change over the day. That's entirely different from animated though. Reading the GNOME config file, seems the background slowly transitions (fades) from one picture to another. See https://gitlab.gnome.org/GNOME/gnome-backgrounds/-/blob/mast...


>There are some popular methods out there like calling `feh --fill-bg` continuously in a bash loop but it sends your CPU usage to an astronomical 40% which drains the laptop battery pretty quickly

Is this true when you have a loop that sleeps for 5 minutes before calling it again? I've always set my wallpapers this way. It's also similar to what I do on Sway. The only alternative I've found is simple enough and still works is using an ad-hoc systemd timer task.

Edit: nevermind, I forgot this is about animated wallpapers. I use a while loop + feh for setting a static wallpaper that changes every 5 minutes.


Did you create those scenes yourself? They look fantastic.


Fantastic work!


When my main computer was Linux laptop, I used xplanet as my desktop background. World clock, basic weather..

This was in 2003. It would get lots of interest when I was working in public places.

Which is why, somewhere over Greenland, a flight attendant came by and very quietly said to me, “I noticed you work on outer space stuff. We just got word over radio that the Space Shuttle blew up.” :-(

Very strange that the memory of that interaction would come to me about 8 hours after a more robust reentry vehicle splashed down in Florida.

http://xplanet.sourceforge.net/


That must have felt very tragic and awkward.


Xplanet is the only animated wallpaper I've even seen used. Most people would try it back in the early 2000 and then come to the conclusion that it wasn't worth the CPU cycles after a few minutes.


I used to care about my desktop background. But as I've gotten older I find the only time I see it is when I close every window, and sometimes I can go for weeks without closing every window. So now I just leave it as the default because I look at it <1% of the time anyway


I mostly work in a terminal, developing in a text editor, and have my terminal background set to 80% opaque so that I can see my background.

Every 15 minutes I pull a random image from /r/earthporn. I enjoy having a "window" into the world :-)

Screenshot: https://imgur.com/fkXYD07


I admit, that's pretty sweet.


I just use a plain black background.


Yup, its ctrl-alt-t the moment DE loads.


I played around with transparent terminals over tranquil underwater videos for a bit. It was nice, but needed a bit too much resource.


I set a solid purple background because I feel unused screen space is a waste.


The only time I ever see it is on the lock screen


Isn't it possible to use mpv for this?

  mpv --wid=0
Causes mpv to draw to the root window.

I even found a guide:

https://github.com/digip/linux-video-wallpaper

Not sure what the performance is like though.


Performance is pretty good, probably even better than TFA, due to the hardware decode of the video.

That said, in both cases transparency of things like terminals is going to be very resource hungry.

Also, if you're doing the --wid=0, throw in --loop there too. :)


I have 3 screens. Amount of pixels that show my desktop: 0

I am honestly confused why, years ago, I spent hours searching for the perfect wallpaper on the internet. And why I spent even more hours making my own, 20 years ago.

Nowadays I usually set one I like when I install the machine and maybe change it 1-4 years later. Is this what growing up feels like? :(


If you have more than one monitor your can keep all windows fully maximized.


most of xscreensaver's hacks will use the root window if you ask them too.

I'm using GLava [1] to put an audio spectrograph up on one side of my desktop, i run it with windowed games and transparency and so on and its never more than a 5% of CPU that I've ever seen.

[1] https://github.com/jarcode-foss/glava

no link for xscreensaver, jwz doesn't like hacker news


xscreensaver is nice when you eliminate all the "busy" modes and then turn down all the sliders on each mode you have left so that it moves very slowly.

the only thing i haven't figured out is how to get the fonts working again.


I love the focus on reducing CPU, GPU, and battery consumption... but it's still going to be distracting.


Apparently many people love distracting wallpaper

https://store.steampowered.com/app/431960/Wallpaper_Engine/


Yeah. I don't mean to be disrespectful to the OP, but what's the point of having wallpapers, anyway? Distraction is one thing, but it's also obstructed when you open a large window. I can kind of understand having a screensaver with a beautiful picture, but today screensavers are things of the past.


It's the same reason I change my icons and desktop theme. I'm gonna stare at this screen for 10+ hours a day, I want it to be beautiful.


At the cost of usable? IDK about that tradeoff. With the wallpaper specifically, it's always covered, at least on all the computers I use.


They look good in /g/ and Reddit desktop threads.


Doesn't the example video show all four cores mostly hovering at around 40-50% CPU usage (with occasional dips to 10-20%)?

What else was the machine doing at the time?


Heh, recording. My thinkpad is a little too slow.


Live wallpapers would be much more compelling if the background had context-awareness of what was in the foreground and could interact and animate in a way that augmented the foreground apps instead of just being pretty. Maybe with smart people, future OSes will make that possible.


Yes, maybe with a little sheep that walked around your windows and teetered over the edges...

https://adrianotiger.github.io/desktopPet/


I miss stuff like this that doesn’t seem nearly as popular these days.


https://cyber.dabamos.de/unix/x11/#xroach

Though it doesn't augment anything, nor does it look particularly pretty...


See the crabs from bell labs

http://lucacardelli.name/Papers/Crabs.pdf


I never saw the point of this, or Active Desktop back in the day.

But the last three releases of Fedora and Gnome have had a sort of animated wallpaper. It's actually just an XML file that defines times and image files for each time. And it's used to darken the wallpaper when the sun sets.

I use the default one that ships with Fedora but the XML file is straightforward and it's simple to make your own.

One thing that will make me use more advanced desktop features is definitely alleviating eye strain.

In that vein, using a CLI tool to check up on Gitlab pipelines is another recent development. Switching back and forth between a dark solarized terminal and a bright Gitlab Firefox window was becoming annoying.

(I know there are lots of CSS tricks you can do in FF to force dark styles on websites but I try to keep my setup as vanilla as possible to ease its management.)


GitLab has a real dark mode in the preferences now. You need to refresh once you select it. The dark syntax highlighting preference plays well with it.

Not that there is anything wrong with a CLI workflow.


Wow, thank you! The pipeline output is still a bit bad contrast but it's so much better.


You can use the binaries from xscreensaver as moving backgrounds. If you execute them directly they'll write to the root window.

Example:

   $ /usr/lib/xscreensaver/moire2 -root


Thanks for sharing this, I've been looking for options for an active wall paper that doesn't passivly wreck my performance. I look forward to giving this a try.


Is there a decent repository for these kind of short animated backgrounds? Ideally pixel graphics like the one in the preview video. I'd like to experiment with this, but a quick duckduckgo search didn't turn up much; some sites were advertising images as animated but they were in fact still images, and most of the others had gifs of varying quality, and weren't even consistently 1080p.


Try stock hd video sites like videezy.com. You'll have to convert the hd videos into suitable format yourself though, but that should be easy enough.


Really wanted this years ago when I was using Compiz/Beryl. Great job finding an efficient (in terms of power and cpu strain) implementation!


I'd like to see a colour pallet cycling xll animated wallpaper http://www.effectgames.com/effect/article-Old_School_Color_C...


Would that work with TWMs like i3? Most animated wallpaper programs I tried didn't work correctly.


Looking at the video, I guess the author uses I3.


Just fyi, I think SDL_LoadBMP relies on sdl2_image; you may want to note that as a dependency.


I believe BMP loading is included into the core SDL2 library, but not other formats, which SDL_image remedies. Here is SDL_Surface.h. SDL_LoadBMP is just a macro using SDL_RWFromFile.

https://github.com/SDL-mirror/SDL/blob/master/include/SDL_su...


Excellent! Some of those backgrounds look like they’re from SvC: Chaos.


I think they are. It's a popular collection of 'fighting game backgrounds with nice pixel art' that get posted around pretty often.


Animated backgrounds not so much, but I really miss screensavers.

Of course they make no sense these days. Still, I liked the interesting displays while my workstation was left to its own thoughts.


The style of the wallpapers and animations reminds me of the Windows 95 Plus theme pack. There was something that animated once every few minutes, but I can't recall what exactly…


Windows Vista had animated backgrounds in the ultimate edition. Was very heavy on CPU though[0].

There used to be a way of displaying websites on the desktop in windows 2000. “Live desktop” I think it was called[1].

[0]: https://en.wikipedia.org/wiki/Windows_DreamScene

[1]: https://en.wikipedia.org/wiki/Active_Desktop?wprov=sfti1


when i see some geometric animations often in small badly encoded videos i wish i would know a repository of programs that create these in order to render them onto the background in a pixel perfect manner without wasting too much resources. but i was not able to find some yet :(


This looks great! Too bad it gives me a headache.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: