I am trying to learn XLib. And I searched throught source of Feh program to understand how to modify root window, but I had no results.
There is code to test root window access, but I don’t understand why it is not working.
#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
Display *disp2;
Window root2;
int main(int argc, char *argv[])
{
disp2 = XOpenDisplay(NULL);
root2 = RootWindow(disp2, DefaultScreen(disp2));
// Generation of random number to set window color
srand(time(NULL));
int i = rand();
// Setting background
// I forgot to change 256 to i
// XSetWindowBackground(disp2, root2, 256 );
XSetWindowBackground(disp2, root2, i
XClearWindow(disp2, root2);
// Showing the random number
printf ("%i \n", i );
return 0;
}
So, what’s wrong in this code?
There is nothing wrong in the code. You’re just trying to print random number. If you need to print random number fro.m 0-256 then try
you can change color of root window in command line
Check this out!
What is your exact problem.
Your question lacks context.