dwmblocks/xgetrootname/xgetrootname.c

22 lines
504 B
C
Raw Normal View History

2020-07-03 21:04:11 +00:00
#include <stdio.h>
#include <X11/Xlib.h>
int
main(void)
2020-07-03 21:04:11 +00:00
{
char *name;
2020-12-04 21:54:41 +00:00
Display *dpy;
2020-07-03 21:04:11 +00:00
if (!(dpy = XOpenDisplay(NULL))) {
fputs("Error: could not open display.\n", stderr);
return 1;
}
if (XFetchName(dpy, DefaultRootWindow(dpy), &name) && name)
puts(name);
2020-07-03 21:04:11 +00:00
else
2020-12-04 21:54:41 +00:00
fputs("No name has been set for the root window.\n", stderr);
2020-07-03 21:04:11 +00:00
XFree(name);
XCloseDisplay(dpy);
return 0;
}