Minimal XGetWindowProperty Example
You can easily see the X11 properties using the xprop command, usually like xprop -root.
However, you might have some reason to directly query X11 properties from a user program. Here is an absolute minimal example of how to do this.
#include <stdio.h>
#include <X11/Xlib.h>
Display *display;
Atom actual_type;
int actual_format;
long nitems;
long bytes;
long *data;
int status;
int main(void)
{
int i;
display = XOpenDisplay(0);
if (!display) {
printf("can't open display");
exit(1);
}
status = XGetWindowProperty(
display,
RootWindow(display, 0),
XInternAtom(display, "_NET_WORKAREA", True), //replace this with your property
0,
(~0L),
False,
AnyPropertyType,
&actual_type,
&actual_format,
&nitems,
&bytes,
(char**)&data);
if (status != Success) {
fprintf(stderr, "status = %d\n", status);
exit(1);
}
printf("actual_type %d\n", actual_type);
printf("actual_format %d\n", actual_format);
printf("nitems %d\n", nitems);
printf("bytes %d\n", bytes);
for (i=0; i < nitems; i++){
printf("data[%d] %d\n", i, data[i]);
}
exit(0);
}Build it like this
ianw@lime:~$ gcc -o testx testx.c -L /usr/X11R6/lib -lX11
