You are not logged in.

#1 2009-12-04 07:59:28

celestialorb
Member
From: Seattle, Washington
Registered: 2009-07-30
Posts: 30

Design Suggestions

Hello everyone.

Recently I decided that I wanted to write a small Python script that would periodically change my background (through a fade transition) to another background image in my backgrounds folder.

My design was fairly simple:

For each image in my backgrounds folder:
    Display image, then let the script sleep.
    Begin the transition to the next image:
       Incrementally increase the alpha of the next image, and slip that on top of the current background.  Save the result in a temporary file and call a program to load it to the background.

However, my script wasn't fast enough for practical usage.  Among other problems, the major one seemed to be the amount of time it took for the other process to actually set the background.  I tried both feh and fbsetbg for this task but neither could execute the command quickly enough.  (If I recall correctly fbsetbg averages around 0.2 seconds for a 1600x1050 image and feh gets around 0.18 seconds)

Since using one of these background setting programs is out of the question (for transitions anyway) is there any other way I could get this to work?  Any utilities I might be able to use?  Maybe setting the background directly from the program?  (I'm using Python for this.)  Or is it simply out of the question because setting a background is just going to take up too much time?

Thanks for any help you're willing to give!  smile

Offline

#2 2009-12-04 11:40:11

sr
Member
Registered: 2009-10-12
Posts: 51

Re: Design Suggestions

If you have compiz installed, maybe you could try the python api? While I've never tried it, it ought to be faster than relying on fbsetbg and the equivalent to do a fade effect.

Offline

#3 2009-12-04 19:28:37

celestialorb
Member
From: Seattle, Washington
Registered: 2009-07-30
Posts: 30

Re: Design Suggestions

Well I don't have compiz installed and I'd rather not rely on it just for this one script.  :-/

Is there maybe someway I can manipulate the background image from Python directly?  I'm willing to switch to another language for this script if there's one out there that can manipulate the background directly.

Offline

#4 2009-12-04 22:08:42

Crows
Member
From: Wales
Registered: 2008-09-05
Posts: 92

Re: Design Suggestions

First thing that comes to mind (may be of no help - just a quick idea) = what about preloading the new image into memory, say by copying it to /tmp, before calling feh etc?

EDIT = also, maybe look into the usual high-speed image libs. I think I remember seeing a python-imlib2 binding somewhere.

Last edited by Crows (2009-12-04 22:10:18)

Offline

#5 2009-12-04 22:27:16

tomd123
Developer
Registered: 2008-08-12
Posts: 565

Re: Design Suggestions

However, my script wasn't fast enough for practical usage.

I don't get it, how is something that runs in the background not practical, even if it is slow? Does your computer freeze during this time it sets the background? Are you having actual side effects, or are you just picky?

Edit: Never mind, I skipped the transition fade, which is probably choppy.  http://vsbabu.org/mt/archives/2002/08/0 … paper.html did you try bsetbg?

Last edited by tomd123 (2009-12-04 22:32:28)

Offline

#6 2009-12-04 23:03:11

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: Design Suggestions

If I understand this right, you are setting the wallpaper for each frame of the fade? I think this will always be a problem no matter how you set the wallpaper.

My suggestion (if you really must have a fade) would be to create an application, maybe using imlib2, that would load the old wallpaper into a window (that is pinned to the root window, so it looks like a regular wallpaper), then load the new one, and perform the fade in that window using imlib, and then once the fade is complete, you can set the new wallpaper, and then close your "fade" window, giving the appearance of a smooth fade between the two.

Actually I don't know how well this would work in practice, but this is how I'd probably attempt it anyway.

Edit: You say the wallpaper setting program is where most of the time comes from, but perhaps disk IO is the cause of this? It might be possible to mount a memory filesystem (such as tmpfs) and write your faded wallpapers to there and set them from there as well. Just a thought though, since Linux most likely caches that enough that it isn't necessary to do this, as well as it being a little overkill for a wallpaper setter, but just another idea tongue

Last edited by HashBox (2009-12-04 23:07:25)

Offline

#7 2009-12-05 01:02:42

celestialorb
Member
From: Seattle, Washington
Registered: 2009-07-30
Posts: 30

Re: Design Suggestions

You say the wallpaper setting program is where most of the time comes from, but perhaps disk IO is the cause of this?

When I save the image I save it within the /tmp directory, which as I understand stores it into the active memory and so disk I/O really isn't a problem in this case.

Offline

#8 2009-12-05 02:28:22

Blazeix
Member
Registered: 2006-10-26
Posts: 25

Re: Design Suggestions

Gnome added support for fading between wallpapers in 2.22, I believe. You might try taking a peek at their implementation to see the general method they used.

Offline

Board footer

Powered by FluxBB