Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
So I've written a program and part what what said program does is set a picture to be the background wallpaper in xorg. This works, with one oddity: programs like urxvt do not correctly show my background through their transparency. If I set the background wallpaper using feh, then that background shows through. In fact, if I first set the wallpaper to one picture with feh and *then* set the wallpaper to a second picture using my program, the wallpaper will change to the second picture, but a subsequent run of urxvt will show the first picture within its transparent window!
I've looked at the source for feh and was confused.
My theory is that there is more than one way to set the background wallpaper and, while the way I am doing it works, it is not the proper way.
Web searching has not revealed anything, oddly enough.
Here is a snippit of the wallpaper-setting part of my program:
Code:
int wall_it(fn)
char *fn; /* file to read and wall */
{
/* file is assumed to be same width and height as screen:
behavior is undefined otherwise */
Imlib_Image img;
Display *dpy;
Pixmap pix;
Window root;
Screen *scn;
int wi_width, wi_height;
/* open up imlib / x-windows stuff */
img = imlib_load_image(fn);
if (!img) {
fprintf(stderr, "wall_it: error loading image\n");
return(DOOPS);
}
imlib_context_set_image(img);
/* get image dimensions */
wi_width = imlib_image_get_width();
wi_height = imlib_image_get_height();
dpy = XOpenDisplay(NULL);
if (!dpy) {
fprintf(stderr, "wall_it: XOpenDisplay error\n");
return(DOOPS);
}
scn = DefaultScreenOfDisplay(dpy);
root = DefaultRootWindow(dpy);
pix = XCreatePixmap(
dpy, root, wi_width, wi_height,
DefaultDepthOfScreen(scn)
);
imlib_context_set_display(dpy);
imlib_context_set_visual(DefaultVisualOfScreen(scn));
imlib_context_set_colormap(DefaultColormapOfScreen(scn));
imlib_context_set_drawable(pix);
/* actually wall that picture */
imlib_render_image_on_drawable(0, 0);
XSetWindowBackgroundPixmap(dpy, root, pix);
XClearWindow(dpy, root);
while (XPending(dpy)) {
XEvent ev;
XNextEvent(dpy, &ev);
}
/* clean up */
XFreePixmap(dpy, pix);
imlib_free_image();
XCloseDisplay(dpy);
/* done */
return(OKDOKEY);
}
Again, my program actually works, in that I see the picture become the new background wallpaper.
you can take a look at some code of mine using imlib2 in a dockapp that sets images to dt, I have to figure it out again every time I play around with it, and have no done so in a very long time. but you should find it interesting. You might find a few things interesting in how to do tiling and such as well and hopefully it will help you to see other ways to do this using imlib2 headers.
you want rootWindow not the layer above it.
--------------- MOD------------------
Okay, with your code you posted I modded it to work with just what you posted and it was not working using the function call with and without RootWindow, then I got an older program I heavily modified using Imlib and tried that and it works like it should with urxvt and seeing the replaced image on the desktop.
Code:
- For fake transparency ~/.Xdefaults :
urxvt*transparent: true
urxvt*shading: 30
using that to set its transparency to test this.
Manipulating the Atoms and changing the desktop settings, updating them this works like you're looking for it to work. It is defiantly a little more complex needing more code to get what you want it to do.
Then I remembered another one I did, so if you are interested in looking at what I did to get what you're looking to do, then go to mhsetroot and download it then look at my source code, it is written in C and it features , resize the images to whatever the user wants then set it to the desktop , and a few more functions for added options on how to display the image on the desktop along with the colors too.
So I've written a program and part what what said program does is set a picture to be the background wallpaper in xorg. This works, with one oddity: programs like urxvt do not correctly show my background through their transparency. If I set the background wallpaper using feh, then that background shows through. In fact, if I first set the wallpaper to one picture with feh and *then* set the wallpaper to a second picture using my program, the wallpaper will change to the second picture, but a subsequent run of urxvt will show the first picture within its transparent window!
I have recently experienced the exact same with xplanet.
Xplanet has a "-transparency" option that specifically addresses that problem. Maybe you should look at the source of that.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.