dwmblocks/xgetrootname/xgetrootname.c

22 lines
503 B
C
Raw Normal View History

2020-07-03 21:04:11 +00:00
#include <stdio.h>
#include <X11/Xlib.h>
int
main()
{
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;
}
2020-07-06 20:28:41 +00:00
if (XFetchName(dpy, DefaultRootWindow(dpy), &name) && name[0])
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;
}