Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am completely new to writing programs for Ubuntu and using the available api. But I wish to write a desktop background changer of my own in C. Are there any api available which would help me write my code. I want the direction to take the first step. Any help in this regard will be greatly appreciated :)

Thank You for your read !!

share|improve this question

closed as off topic by Ringtail, hbdgaf, jrg Apr 5 '12 at 13:21

Questions on Ask Ubuntu are expected to relate to Ubuntu within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

    
the easiest way i can think of is to make a window containing the background you want with no border and set it to always on bottom. not the best solution, but it works quickly and you can use gtk/pygtk to get it done. –  hbdgaf Feb 17 '12 at 6:47
    
exact duplicate: stackoverflow.com/questions/1220826/… –  hbdgaf Feb 17 '12 at 7:00
    
adding the comment to check on activity. Have you solved the issue another way? or is it an abandoned question? –  hbdgaf Mar 30 '12 at 20:11

1 Answer 1

Here are the contents of the accepted answer for the same question on SO:

You should be able to deal with the root window (which the wallpaper is, in fact) by studying the source of xsetroot.c, the most interesting part of which I copypaste here:

static void
SetBackgroundToBitmap(Pixmap bitmap, unsigned int width, unsigned int height)
{
    Pixmap pix;
    GC gc;
    XGCValues gc_init;

    gc_init.foreground = NameToPixel(fore_color, BlackPixel(dpy, screen));
    gc_init.background = NameToPixel(back_color, WhitePixel(dpy, screen));
    if (reverse) {
        unsigned long temp=gc_init.foreground;
        gc_init.foreground=gc_init.background;
        gc_init.background=temp;
    }
    gc = XCreateGC(dpy, root, GCForeground|GCBackground, &gc_init);
    pix = XCreatePixmap(dpy, root, width, height,
                        (unsigned int)DefaultDepth(dpy, screen));
    XCopyPlane(dpy, bitmap, pix, gc, 0, 0, width, height, 0, 0, (unsigned long)1);
    XSetWindowBackgroundPixmap(dpy, root, pix);
    XFreeGC(dpy, gc);
    XFreePixmap(dpy, bitmap);
    if (save_colors)
        save_pixmap = pix;
    else
        XFreePixmap(dpy, pix);
    XClearWindow(dpy, root);
    unsave_past = 1;
}
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.